2ca83614e7
Some of the test scripts create temporary files, which we remove at the end. Except that we usually forgot to remove them on some exit paths. To avoid this problem in future, this modifies the scripts to use the shell's trap 0 functionality to automatically remove the temporaries on any exit. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
33 lines
442 B
Bash
Executable file
33 lines
442 B
Bash
Executable file
#! /bin/sh
|
|
|
|
. ./tests.sh
|
|
|
|
LOG=tmp.log.$$
|
|
EXPECT=tmp.expect.$$
|
|
rm -f $LOG $EXPECT
|
|
trap "rm -f $LOG $EXPECT" 0
|
|
|
|
expect="$1"
|
|
echo "$expect" >$EXPECT
|
|
shift
|
|
|
|
verbose_run_log "$LOG" $VALGRIND "$DTGET" "$@"
|
|
ret="$?"
|
|
|
|
if [ "$ret" -ne 0 -a "$expect" = "ERR" ]; then
|
|
PASS
|
|
fi
|
|
|
|
if [ "$ret" -gt 127 ]; then
|
|
signame=$(kill -l $[ret - 128])
|
|
FAIL "Killed by SIG$signame"
|
|
fi
|
|
|
|
diff $EXPECT $LOG
|
|
ret="$?"
|
|
|
|
if [ "$ret" -eq 0 ]; then
|
|
PASS
|
|
else
|
|
FAIL
|
|
fi
|