Skip to content

Commit

Permalink
Improve error handling in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gemesa committed Oct 28, 2023
1 parent 515f4b5 commit 958e848
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ arch=$(uname -m)
so=$(uname -s) # We use `-s` because `-o` is not supported on Mac OS X
so=${so#*/}
version=$(sed -n 's/^.*VERSION \"\([0-9]\.[0-9]*\)\"/\1/p' $INC_DIR/common.h)
err=0

function test_build
{
Expand All @@ -40,6 +41,7 @@ function test_binary
eval ${onsuccess}
else
eval ${onfailure}
err=1
return # Stop at error
fi
}
Expand All @@ -64,6 +66,7 @@ function test_binary_using_all_formats
eval ${onsuccess}
else
eval ${onfailure}
err=1
break # Stop at 1st error
fi
done
Expand Down Expand Up @@ -109,6 +112,7 @@ function test_binary_output_against_expected_output
eval ${onfailure}
#echo "Showing differences:"
#head -n 5 tmp.diff
err=1
return # Stop at error
fi
}
Expand Down Expand Up @@ -288,18 +292,23 @@ case "$1" in
if [ $# -ne 2 ]
then
echo "missing argument: use $0 pe32 <binary file>"
exit 1
else
test_pe32 $2
exit $err
fi
;;
"pe64")
test_pe64 ;;
test_pe64
exit $err ;;
"regression")
if [ $# -ne 2 ]
then
echo "missing argument: use $0 regression <binary file>"
exit 1
else
test_regression $2
exit $err
fi
;;
*)
Expand Down
1 change: 1 addition & 0 deletions tests/valgrind_pedis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ for sample in $samples; do
done

echo "$n samples analyzed. $err errors." > /dev/fd/2
exit $err
1 change: 1 addition & 0 deletions tests/valgrind_pepack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ for sample in $samples; do
done

echo "$n samples analyzed. $err errors." > /dev/fd/2
exit $err
1 change: 1 addition & 0 deletions tests/valgrind_pesec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ for sample in $samples; do
done

echo "$n samples analyzed. $err errors." > /dev/fd/2
exit $err
1 change: 1 addition & 0 deletions tests/valgrind_readpe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ for sample in $samples; do
done

echo "$n samples analyzed. $err errors." > /dev/fd/2
exit $err

0 comments on commit 958e848

Please sign in to comment.