From 10076acaddfa611214e42e0402c3578bc69cada9 Mon Sep 17 00:00:00 2001 From: Ashish Pandey Date: Thu, 12 Jan 2017 14:48:28 +0530 Subject: tests/include : EXPECT_WITHIN takes full time even if expression matches Problem: For all the tests using get_pending_heal_count, EXPECT_WITHIN is taking full time given to it even if the heal count matches with expected value. Solution: 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 matching with the expression without quotes. That is why it was passing. Remove double quotes in "if condition" in EXPECT_WITHIN and match as we are matching it in test_expect_footer. >Change-Id: Ia161594774d05b9b888efb2f7ed1950590d8ac1b >BUG: 1412549 >Signed-off-by: Ashish Pandey >Reviewed-on: https://review.gluster.org/16382 >Smoke: Gluster Build System >Reviewed-by: Jeff Darcy >NetBSD-regression: NetBSD Build System >CentOS-regression: Gluster Build System >Reviewed-by: Raghavendra Talur >Signed-off-by: Ashish Pandey Change-Id: Ia161594774d05b9b888efb2f7ed1950590d8ac1b BUG: 1416285 Signed-off-by: Ashish Pandey Reviewed-on: https://review.gluster.org/16467 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Shyamsundar Ranganathan --- tests/include.rc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/include.rc b/tests/include.rc index b83972a111b..4591859cc01 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -235,7 +235,7 @@ function test_expect_not_footer() err="Got \"$a\" when not expecting it" fi - ! [[ "$a" =~ "$e" ]]; + ! [[ "$a" =~ $e ]]; test_footer "$lineno" "$err"; } @@ -291,6 +291,10 @@ function _TEST() test_footer "$TESTLINE"; } +#This function should be used carefully. +#The expected regex, given to this function, should be +#used within ^ and $ to match exactly with the output of +#command. function _EXPECT_WITHIN() { TESTLINE=$1 @@ -316,7 +320,7 @@ function _EXPECT_WITHIN() fi ## Check match success - if [[ "$a" =~ "$e" ]]; then + if [[ "$a" =~ $e ]]; then break; fi sleep 1; -- cgit