[Bugs] [Bug 1412549] EXPECT_WITHIN is taking too much time even if the result matches with expected value

bugzilla at redhat.com bugzilla at redhat.com
Thu Jan 12 09:36:06 UTC 2017


https://bugzilla.redhat.com/show_bug.cgi?id=1412549



--- Comment #1 from Ashish Pandey <aspandey at redhat.com> ---



    RC: 
    In most of the tests, to check heal count, wildcards are
    being used. In EXPECT_WITHIN, in if condition, when we use it in
    double quotes (" "), it gives string with wildcards which does not
    match with the output of get_pending_heal_count.
    For example, (0 =~ ^0$).
    So, "while" loop was running for full time and at the end, after
    coming out of loop, in next if condition it was mathing with the
    expression without quotes. That is why it was passing.

function _EXPECT_WITHIN()
{
        TESTLINE=$1
        shift;

        local timeout=$1
        shift;

        G_LOG $TESTLINE "$@";
        test_header "$@"

        e=$1;
        a="";
        shift;

        local endtime=$(( ${timeout}+`date +%s` ))

        while [ `date +%s` -lt $endtime ]; do
                a=$("$@" | tail -1 ; exit ${PIPESTATUS[0]})
                ## Check command success
                if [ $? -ne 0 ]; then
                        break;
                fi

                ## Check match success

                if [[ "$a" =~ "$e" ]]; then <<<<<<<<<<< This is the issue
                        break;
                fi
                sleep 1;
        done

So after this while loop actually, it is test_expect_footer which checks and
matches the value. This function is using expression without double quotes.

function test_expect_footer()
{
        local lineno=$1
        local e=$2
        local a=$3
        local err=""

        if ! [[ "$a" =~ $e ]]; then
                err="Got \"$a\" instead of \"$e\""
        fi
        [[ "$a" =~ $e ]];

        test_footer "$lineno" "$err";
}



Solution :    
    Remove double quotes in "if condition" in EXPECT_WITHIN and match
    as we are matching it in test_expect_footer.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
Unsubscribe from this bug https://bugzilla.redhat.com/token.cgi?t=CIxqoF7QBl&a=cc_unsubscribe


More information about the Bugs mailing list