X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Fbenchmark%2Fcommon.sh;fp=tests%2Fbenchmark%2Fcommon.sh;h=4dbc5671edbb0f91b09dae3aba3d296440d434dc;hp=1f5f07f96622201075e02b33c4f284bad27366a9;hb=748f9af1f0e61f6f5133b45ed7dcf1f071246b9e;hpb=2f6618651c31c05ba1adbb5cdcf0d92980c38f38 diff --git a/tests/benchmark/common.sh b/tests/benchmark/common.sh index 1f5f07f..4dbc567 100755 --- a/tests/benchmark/common.sh +++ b/tests/benchmark/common.sh @@ -2,25 +2,35 @@ # This file is meant to be sourced from other tests scripts. # -if [ -x "$URCU_TEST_TIME_BIN" ]; then - test_time_bin="$URCU_TEST_TIME_BIN" -elif [ -x "/usr/bin/time" ]; then - test_time_bin="/usr/bin/time" -else - test_time_bin="" -fi +cleanup() { + if [ x"$TMPFILE" != "x" ]; then + rm -f "$TMPFILE" + fi -function cleanup() -{ - if [ x"$tmpfile" != x"" ]; then - rm -f $tmpfile - fi + # Call the tap.sh exit cleanup code + _exit } -function xseq () { +xseq() { i=$1 while [[ "$i" -le "$2" ]]; do echo "$i" - i=$(expr $i + 1) + i=$(( i + 1 )) done } + +# Set TEST_TIME_BIN +if [ -x "$URCU_TEST_TIME_BIN" ]; then + TEST_TIME_BIN="$URCU_TEST_TIME_BIN" +elif [ -x "/usr/bin/time" ]; then + TEST_TIME_BIN="/usr/bin/time" +else + TEST_TIME_BIN="" +fi +export TEST_TIME_BIN + +# Create a temporary file for tests output +TMPFILE=$(mktemp) + +# Set traps to delete the temporary file on exit +trap cleanup EXIT