diff options
author | Andrés <andmarti@gmail.com> | 2021-06-07 09:43:36 -0300 |
---|---|---|
committer | Andrés <andmarti@gmail.com> | 2021-06-07 09:43:36 -0300 |
commit | c7609838f9cf28362dae790dcb0a7f59e380a43d (patch) | |
tree | de5d28fe564b2f3d2824dad206b630bc70f6993d /tests | |
parent | 964c48f97419c15fb601e16d65e4b7ee2f59cd4c (diff) |
Added more valgrind controls on tests
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/assert.sh | 14 | ||||
-rwxr-xr-x | tests/test1.sh | 6 | ||||
-rwxr-xr-x | tests/test2.sh | 5 | ||||
-rwxr-xr-x | tests/test3.sh | 5 | ||||
-rwxr-xr-x | tests/test4.sh | 5 |
5 files changed, 29 insertions, 6 deletions
diff --git a/tests/assert.sh b/tests/assert.sh index 96cce81..3ed5eaf 100755 --- a/tests/assert.sh +++ b/tests/assert.sh @@ -116,22 +116,24 @@ assert() { # Check in file ($1) for a pattern ($2) # if found, assert if $3 condition is not met +# or if $3 condition is empty assert_iffound_notcond() { (( tests_ran++ )) || : [[ -z "$DISCOVERONLY" ]] || return file=$1 pattern=$2 assert_ne_cond=$3 - #echo ":$file." - #echo ":$pattern." - #echo ":$assert_ne_cond." - grepres="$(grep "$file" -e "$pattern" | grep -v "$assert_ne_cond")" || true - #echo $grepres + + if [[ -z "$assert_ne_cond" ]]; then + grepres="$(grep "$file" -e "$pattern")" || true + else + grepres="$(grep "$file" -e "$pattern" | grep -v "$assert_ne_cond")" || true + fi + if [[ -z "$grepres" ]]; then [[ -z "$DEBUG" ]] || echo -n . return fi - #echo leak found _assert_fail "$grepres" $file "$1" "$3" } diff --git a/tests/test1.sh b/tests/test1.sh index 0e5d757..7cd3970 100755 --- a/tests/test1.sh +++ b/tests/test1.sh @@ -9,11 +9,17 @@ NAME=test1 VALGRIND_CMD='valgrind -v --log-file=${NAME}_vallog --tool=memcheck --track-origins=yes --leak-check=full --show-leak-kinds=all --show-reachable=no' . assert.sh assert "echo GETNUM C2 | $VALGRIND_CMD ../src/sc-im ${NAME}.sc --nocurses --nodebug --quit_afterload 2>&1 |grep -v '^$\|Interp'" "81" +echo "Invalid write of size" >> ${NAME}_vallog #we check valgrind log 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" +assert_iffound_notcond ${NAME}_vallog "Uninitialised value was created by a heap allocation" "!" +assert_iffound_notcond ${NAME}_vallog "Conditional jump or move depends on uninitialised value" +assert_iffound_notcond ${NAME}_vallog "Invalid read of size" +assert_iffound_notcond ${NAME}_vallog "Invalid write of size" +assert_iffound_notcond ${NAME}_vallog "Invalid free() / delete" if [ "$1" != "keep-vallog" ];then rm ${NAME}_vallog fi diff --git a/tests/test2.sh b/tests/test2.sh index b58e440..2453c62 100755 --- a/tests/test2.sh +++ b/tests/test2.sh @@ -14,6 +14,11 @@ assert "echo GETNUM C2 | $VALGRIND_CMD ../src/sc-im ${NAME}.sc --nocurses --node 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" +assert_iffound_notcond ${NAME}_vallog "Uninitialised value was created by a heap allocation" "!" +assert_iffound_notcond ${NAME}_vallog "Conditional jump or move depends on uninitialised value" +assert_iffound_notcond ${NAME}_vallog "Invalid read of size" +assert_iffound_notcond ${NAME}_vallog "Invalid write of size" +assert_iffound_notcond ${NAME}_vallog "Invalid free() / delete" if [ "$1" != "keep-vallog" ];then rm ${NAME}_vallog fi diff --git a/tests/test3.sh b/tests/test3.sh index a262e99..ccc1740 100755 --- a/tests/test3.sh +++ b/tests/test3.sh @@ -14,6 +14,11 @@ assert "echo GETNUM A0 | $VALGRIND_CMD ../src/sc-im ${NAME}.sc --nocurses --node 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" +assert_iffound_notcond ${NAME}_vallog "Uninitialised value was created by a heap allocation" "!" +assert_iffound_notcond ${NAME}_vallog "Conditional jump or move depends on uninitialised value" +assert_iffound_notcond ${NAME}_vallog "Invalid read of size" +assert_iffound_notcond ${NAME}_vallog "Invalid write of size" +assert_iffound_notcond ${NAME}_vallog "Invalid free() / delete" if [ "$1" != "keep-vallog" ];then rm ${NAME}_vallog fi diff --git a/tests/test4.sh b/tests/test4.sh index 18bad96..a132939 100755 --- a/tests/test4.sh +++ b/tests/test4.sh @@ -16,6 +16,11 @@ assert "echo -e '${CMD}' | $VALGRIND_CMD ../src/sc-im ${NAME}.sc --nocurses --no 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" +assert_iffound_notcond ${NAME}_vallog "Uninitialised value was created by a heap allocation" "!" +assert_iffound_notcond ${NAME}_vallog "Conditional jump or move depends on uninitialised value" +assert_iffound_notcond ${NAME}_vallog "Invalid read of size" +assert_iffound_notcond ${NAME}_vallog "Invalid write of size" +assert_iffound_notcond ${NAME}_vallog "Invalid free() / delete" if [ "$1" != "keep-vallog" ];then rm ${NAME}_vallog fi |