diff options
author | Andrés <andmarti@gmail.com> | 2021-06-04 14:02:05 -0300 |
---|---|---|
committer | Andrés <andmarti@gmail.com> | 2021-06-04 14:02:05 -0300 |
commit | 4b69d9ceb3cb771a60fa62839b9462d621e21925 (patch) | |
tree | ce1059067b7a3dcd9c8352a707b273eb9202f8ce /tests | |
parent | 35a9175456c5518cad3c5d278876dd1219bd24a2 (diff) |
Added optional parameter to testN.sh scripts to prevent valgrind logs removal
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/assert.sh | 4 | ||||
-rwxr-xr-x | tests/run_all_tests.sh | 2 | ||||
-rwxr-xr-x | tests/test1.sh | 10 | ||||
-rwxr-xr-x | tests/test2.sh | 10 | ||||
-rwxr-xr-x | tests/test3.sh | 10 | ||||
-rwxr-xr-x | tests/test4.sh | 10 |
6 files changed, 28 insertions, 18 deletions
diff --git a/tests/assert.sh b/tests/assert.sh index c7bcf1a..96cce81 100755 --- a/tests/assert.sh +++ b/tests/assert.sh @@ -114,7 +114,9 @@ assert() { _assert_fail "expected $expected${_indent}got $result" "$1" "$3" } -assert_iffound() { +# Check in file ($1) for a pattern ($2) +# if found, assert if $3 condition is not met +assert_iffound_notcond() { (( tests_ran++ )) || : [[ -z "$DISCOVERONLY" ]] || return file=$1 diff --git a/tests/run_all_tests.sh b/tests/run_all_tests.sh index cac47e1..4637d29 100755 --- a/tests/run_all_tests.sh +++ b/tests/run_all_tests.sh @@ -2,5 +2,5 @@ for i in test*.sh do echo "Testing $i" - /bin/bash $i + /bin/bash $i keep-vallog done diff --git a/tests/test1.sh b/tests/test1.sh index 37d92aa..0e5d757 100755 --- a/tests/test1.sh +++ b/tests/test1.sh @@ -11,9 +11,11 @@ VALGRIND_CMD='valgrind -v --log-file=${NAME}_vallog --tool=memcheck --track-orig assert "echo GETNUM C2 | $VALGRIND_CMD ../src/sc-im ${NAME}.sc --nocurses --nodebug --quit_afterload 2>&1 |grep -v '^$\|Interp'" "81" #we check valgrind log -assert_iffound ${NAME}_vallog "definitely lost.*bytes" "0 bytes" -assert_iffound ${NAME}_vallog "indirectly lost.*bytes" "0 bytes" -assert_iffound ${NAME}_vallog "possibly lost.*bytes" "0 bytes" -rm ${NAME}_vallog +assert_iffound_notcond ${NAME}_vallog "definitely lost.*bytes" "0 bytes" +assert_iffound_notcond ${NAME}_vallog "indirectly lost.*bytes" "0 bytes" +assert_iffound_notcond ${NAME}_vallog "possibly lost.*bytes" "0 bytes" +if [ "$1" != "keep-vallog" ];then + rm ${NAME}_vallog +fi assert_end ${NAME} diff --git a/tests/test2.sh b/tests/test2.sh index f933668..b58e440 100755 --- a/tests/test2.sh +++ b/tests/test2.sh @@ -11,9 +11,11 @@ VALGRIND_CMD='valgrind -v --log-file=${NAME}_vallog --tool=memcheck --track-orig assert "echo GETNUM C2 | $VALGRIND_CMD ../src/sc-im ${NAME}.sc --nocurses --nodebug --quit_afterload 2>&1 |grep -v '^$\|Interp\|left'" "81" #we check valgrind log -assert_iffound ${NAME}_vallog "definitely lost.*bytes" "0 bytes" -assert_iffound ${NAME}_vallog "indirectly lost.*bytes" "0 bytes" -assert_iffound ${NAME}_vallog "possibly lost.*bytes" "0 bytes" -rm ${NAME}_vallog +assert_iffound_notcond ${NAME}_vallog "definitely lost.*bytes" "0 bytes" +assert_iffound_notcond ${NAME}_vallog "indirectly lost.*bytes" "0 bytes" +assert_iffound_notcond ${NAME}_vallog "possibly lost.*bytes" "0 bytes" +if [ "$1" != "keep-vallog" ];then + rm ${NAME}_vallog +fi assert_end ${NAME} diff --git a/tests/test3.sh b/tests/test3.sh index 8e68a4f..a262e99 100755 --- a/tests/test3.sh +++ b/tests/test3.sh @@ -11,9 +11,11 @@ VALGRIND_CMD='valgrind -v --log-file=${NAME}_vallog --tool=memcheck --track-orig assert "echo GETNUM A0 | $VALGRIND_CMD ../src/sc-im ${NAME}.sc --nocurses --nodebug --quit_afterload 2>&1 |grep -v '^$\|Interp\|left'" "3.3" #we check valgrind log -assert_iffound ${NAME}_vallog "definitely lost.*bytes" "0 bytes" -assert_iffound ${NAME}_vallog "indirectly lost.*bytes" "0 bytes" -assert_iffound ${NAME}_vallog "possibly lost.*bytes" "0 bytes" -rm ${NAME}_vallog +assert_iffound_notcond ${NAME}_vallog "definitely lost.*bytes" "0 bytes" +assert_iffound_notcond ${NAME}_vallog "indirectly lost.*bytes" "0 bytes" +assert_iffound_notcond ${NAME}_vallog "possibly lost.*bytes" "0 bytes" +if [ "$1" != "keep-vallog" ];then + rm ${NAME}_vallog +fi assert_end ${NAME} diff --git a/tests/test4.sh b/tests/test4.sh index 7cf29d1..18bad96 100755 --- a/tests/test4.sh +++ b/tests/test4.sh @@ -13,9 +13,11 @@ CMD='LET A2 = 1\nUNDO\nGETNUM A0\nGETNUM {"dos"}!B3' assert "echo -e '${CMD}' | $VALGRIND_CMD ../src/sc-im ${NAME}.sc --nocurses --nodebug --quit_afterload 2>&1 |grep -v '^$\|Interp\|left\|Change'" "2.3\n0" #we check valgrind log -assert_iffound ${NAME}_vallog "definitely lost.*bytes" "0 bytes" -assert_iffound ${NAME}_vallog "indirectly lost.*bytes" "0 bytes" -assert_iffound ${NAME}_vallog "possibly lost.*bytes" "0 bytes" -rm ${NAME}_vallog +assert_iffound_notcond ${NAME}_vallog "definitely lost.*bytes" "0 bytes" +assert_iffound_notcond ${NAME}_vallog "indirectly lost.*bytes" "0 bytes" +assert_iffound_notcond ${NAME}_vallog "possibly lost.*bytes" "0 bytes" +if [ "$1" != "keep-vallog" ];then + rm ${NAME}_vallog +fi assert_end ${NAME} |