diff options
author | Morgan Deters <mdeters@gmail.com> | 2011-03-14 21:00:34 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2011-03-14 21:00:34 +0000 |
commit | 054455fe9b57a4f5df4702aaabcf77ca71d8e70a (patch) | |
tree | b504fb8f264d3f4ffecbd7752959d7502fe78b82 /test/regress | |
parent | c5135c27ed486e0808c29b20857c54d1fe6bfe3e (diff) |
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
Diffstat (limited to 'test/regress')
-rwxr-xr-x | test/regress/run_regression | 34 |
1 files changed, 20 insertions, 14 deletions
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" |