summaryrefslogtreecommitdiffstats
path: root/tests/include.rc
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2013-11-12 20:27:35 +0530
committerAnand Avati <avati@redhat.com>2013-11-24 20:28:38 -0800
commit07a3b04d5ce1d7a22a4ce01f1b6b8f8fc6ffbb05 (patch)
tree50eb52a7852ca8d1c50eda7602cc4ecb23ad75ad /tests/include.rc
parent6e7817232ca39330a9e8ba2220f5636eeec375af (diff)
tests: add EXPECT_NOT macro
We needed this macro while writing test cases for quota. With quota, a directory size is only guaranteed to be within some margin of quota limit, but not an accurate number. With not knowing what size to expect and EXPECT macro not complete enough to accept ranges of sizes, we can atleast write test-cases with EXPECT_NOT macro. After copying data to an empty file, it will be guaranteed the size will not be zero. This is good enough for quota test cases. Change-Id: I722ebd68044716a5eeaf0bd7e9aae61df8469017 BUG: 1022995 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-on: http://review.gluster.org/6253 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'tests/include.rc')
-rw-r--r--tests/include.rc33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/include.rc b/tests/include.rc
index bb541eaa1..de28241c2 100644
--- a/tests/include.rc
+++ b/tests/include.rc
@@ -14,7 +14,7 @@ mkdir -p $B0;
mkdir -p $M0 $M1;
mkdir -p $N0 $N1;
-testcnt=`egrep '^[[:space:]]*(EXPECT|TEST|EXPECT_WITHIN|EXPECT_KEYWORD)[[:space:]]' $0 | wc -l`
+testcnt=`egrep '^[[:space:]]*(EXPECT|EXPECT_NOT|TEST|EXPECT_WITHIN|EXPECT_KEYWORD)[[:space:]]' $0 | wc -l`
expect_tests=`egrep '^[[:space:]]*TESTS_EXPECTED_IN_LOOP[[:space:]]*' $0`
x_ifs=$IFS
@@ -71,6 +71,7 @@ function test_expect_footer()
err="Got \"$a\" instead of \"$e\""
fi
[[ "x${e}" == "x${a}" ]];
+
test_footer "$err";
}
@@ -89,6 +90,35 @@ function _EXPECT()
test_expect_footer "$e" "$a";
}
+function test_expect_not_footer()
+{
+ local e=$1
+ local a=$2
+ local err=""
+
+ if [ "x${e}" == "x${a}" ]; then
+ err="Got \"$a\" when not expecting it"
+ fi
+
+ [[ "x${e}" != "x${a}" ]];
+ test_footer "$err";
+}
+
+function _EXPECT_NOT()
+{
+ TESTLINE=$1;
+ shift;
+ local a=""
+
+ test_header "$@";
+
+ e="$1";
+ shift;
+ a=$("$@" | tail -1)
+
+ test_expect_not_footer "$e" "$a";
+}
+
function _EXPECT_KEYWORD()
{
TESTLINE=$1;
@@ -238,6 +268,7 @@ function process_leak_count ()
}
alias EXPECT='_EXPECT $LINENO'
+alias EXPECT_NOT='_EXPECT_NOT $LINENO'
alias TEST='_TEST $LINENO'
alias EXPECT_WITHIN='_EXPECT_WITHIN $LINENO'
alias EXPECT_KEYWORD='_EXPECT_KEYWORD $LINENO'