From: Morgan Deters Date: Mon, 14 Mar 2011 21:00:34 +0000 (+0000) Subject: change to the run_regression script to better manage temporary files; hopefully this... X-Git-Tag: cvc5-1.0.0~8660 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=054455fe9b57a4f5df4702aaabcf77ca71d8e70a;p=cvc5.git change to the run_regression script to better manage temporary files; hopefully this will somewhat alleviate the problem with all the junk files in /tmp --- diff --git a/test/regress/run_regression b/test/regress/run_regression index 9c0eaa9db..f5c8adb15 100755 --- a/test/regress/run_regression +++ b/test/regress/run_regression @@ -47,7 +47,7 @@ if expr "$benchmark" : '.*\.smt$' &>/dev/null; then expected_error=`grep '^% EXPECT-ERROR: ' "$benchmark" | sed 's,^% EXPECT-ERROR: ,,'` expected_exit_status=`grep -m 1 '^% EXIT: ' "$benchmark" | sed 's,^% EXIT: ,,'` command_line=`grep '^% COMMAND-LINE: ' "$benchmark" | sed 's,^% COMMAND-LINE: ,,'` - tmpbenchmark=`mktemp -t cvc4_benchmark.XXXXXXXXXX`.smt + gettemp tmpbenchmark cvc4_benchmark.$$.XXXXXXXXXX.smt grep -v '^% \(EXPECT\|EXPECT-ERROR\|EXIT\|COMMAND-LINE\): ' "$benchmark" >"$tmpbenchmark" if [ -z "$expected_exit_status" ]; then error "cannot determine expected exit status of \`$benchmark': please use \`% EXIT:' gesture" @@ -78,7 +78,7 @@ elif expr "$benchmark" : '.*\.smt2$' &>/dev/null; then expected_error=`grep '^% EXPECT-ERROR: ' "$benchmark" | sed 's,^% EXPECT-ERROR: ,,'` expected_exit_status=`grep -m 1 '^% EXIT: ' "$benchmark" | sed 's,^% EXIT: ,,'` command_line=`grep '^% COMMAND-LINE: ' "$benchmark" | sed 's,^% COMMAND-LINE: ,,'` - tmpbenchmark=`mktemp -t cvc4_benchmark.XXXXXXXXXX`.smt2 + gettemp tmpbenchmark cvc4_benchmark.$$.XXXXXXXXXX.smt2 grep -v '^% \(EXPECT\|EXPECT-ERROR\|EXIT\|COMMAND-LINE\): ' "$benchmark" >"$tmpbenchmark" if [ -z "$expected_exit_status" ]; then error "cannot determine expected exit status of \`$benchmark': please use \`% EXIT:' gesture" @@ -111,11 +111,24 @@ else error "benchmark \`$benchmark' must be *.cvc or *.smt or *.smt2" fi -expoutfile=`mktemp -t cvc4_expect_stdout.XXXXXXXXXX` -experrfile=`mktemp -t cvc4_expect_stderr.XXXXXXXXXX` -outfile=`mktemp -t cvc4_stdout.XXXXXXXXXX` -errfile=`mktemp -t cvc4_stderr.XXXXXXXXXX` -exitstatusfile=`mktemp -t cvc4_exitstatus.XXXXXXXXXX` +# gettemp() and its associated tempfiles[] array are intended to never +# allow a temporary file to leak---the trap ensures that when this script +# exits, whether via a regular exit or an -INT or other signal, the +# temp files are deleted. +declare -ax tempfiles +trap -- 'test ${#tempfiles[@]} -gt 0 && rm -vf "${tempfiles[@]}"' EXIT +function gettemp { + temp="`mktemp -t "$2"`" + tempfiles[${#tempfiles[@]}]="$temp" + eval "$1"="$temp" +} + +gettemp expoutfile cvc4_expect_stdout.$$.XXXXXXXXXX +gettemp experrfile cvc4_expect_stderr.$$.XXXXXXXXXX +gettemp outfile cvc4_stdout.$$.XXXXXXXXXX +gettemp errfile cvc4_stderr.$$.XXXXXXXXXX +gettemp exitstatusfile cvc4_exitstatus.$$.XXXXXXXXXX + if [ -z "$expected_output" ]; then # in case expected stdout output is empty, make sure we don't differ # by a newline, which we would if we echo "" >"$expoutfile" @@ -150,13 +163,6 @@ diffserr=`diff -u "$experrfile" "$errfile"` diffexiterr=$? exit_status=`cat "$exitstatusfile"` -rm -f "$expoutfile" -rm -f "$experrfile" -rm -f "$outfile" -rm -f "$errfile" -rm -f "$exitstatusfile" -test -n "$tmpbenchmark" && rm -f "$tmpbenchmark" - exitcode=0 if [ $diffexit -ne 0 ]; then echo "$prog: error: differences between expected and actual output on stdout"