more functional general tester; better signal handling and details in xv6 tester
This commit is contained in:
@@ -117,11 +117,12 @@ run_and_check () {
|
|||||||
|
|
||||||
# usage: call when args not parsed, or when help needed
|
# usage: call when args not parsed, or when help needed
|
||||||
usage () {
|
usage () {
|
||||||
echo "usage: run-tests.sh [-h] [-v] [-t test] [-c] [-d testdir]"
|
echo "usage: run-tests.sh [-h] [-v] [-t test] [-c] [-s] [-d testdir]"
|
||||||
echo " -h help message"
|
echo " -h help message"
|
||||||
echo " -v verbose"
|
echo " -v verbose"
|
||||||
echo " -t n run only test n"
|
echo " -t n run only test n"
|
||||||
echo " -c continue even after failure"
|
echo " -c continue even after failure"
|
||||||
|
echo " -s skip pre-test initialization"
|
||||||
echo " -d testdir run tests from testdir"
|
echo " -d testdir run tests from testdir"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -132,9 +133,10 @@ usage () {
|
|||||||
verbose=0
|
verbose=0
|
||||||
testdir="tests"
|
testdir="tests"
|
||||||
contrunning=0
|
contrunning=0
|
||||||
|
skippre=0
|
||||||
specific=""
|
specific=""
|
||||||
|
|
||||||
args=`getopt hvct:d: $*`
|
args=`getopt hvsct:d: $*`
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
usage; exit 1
|
usage; exit 1
|
||||||
fi
|
fi
|
||||||
@@ -152,6 +154,9 @@ for i; do
|
|||||||
-c)
|
-c)
|
||||||
contrunning=1
|
contrunning=1
|
||||||
shift;;
|
shift;;
|
||||||
|
-s)
|
||||||
|
skippre=1
|
||||||
|
shift;;
|
||||||
-t)
|
-t)
|
||||||
specific=$2
|
specific=$2
|
||||||
shift
|
shift
|
||||||
@@ -176,7 +181,16 @@ if [[ ! -d tests-out ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# do a one-time setup step
|
# do a one-time setup step
|
||||||
# xxx
|
if (( $skippre == 0 )); then
|
||||||
|
if [[ -f tests/pre ]]; then
|
||||||
|
builtin echo -e "\e[32mdoing one-time pre-test\e[0m (use -s to suppress)"
|
||||||
|
source tests/pre
|
||||||
|
if (( $? != 0 )); then
|
||||||
|
echo "pre-test: failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# run just one test
|
# run just one test
|
||||||
if [[ $specific != "" ]]; then
|
if [[ $specific != "" ]]; then
|
||||||
@@ -192,13 +206,3 @@ while true; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,38 @@
|
|||||||
#! /usr/bin/env expect
|
#! /usr/bin/env expect
|
||||||
|
|
||||||
|
proc shutdown {} {
|
||||||
|
# send command to halt qemu (ctrl-a x)
|
||||||
|
# https://stackoverflow.com/questions/27050473/how-to-send-ctrl-a-then-d-in-expect
|
||||||
|
send "\x01"; send "x"
|
||||||
|
# make sure to wait for it all to stop
|
||||||
|
# (without this, script was terminating before qemu quit -> bad)
|
||||||
|
expect eof
|
||||||
|
}
|
||||||
|
|
||||||
# turn off timeout (perhaps make this flexible later)
|
# turn off timeout (perhaps make this flexible later)
|
||||||
set timeout -1
|
set timeout -1
|
||||||
|
|
||||||
# build and launch xv6 on qemu
|
# build and launch xv6 on qemu
|
||||||
spawn make qemu-nox
|
spawn make [lindex $argv 0] -f [lindex $argv 1] qemu-nox
|
||||||
|
|
||||||
|
trap {
|
||||||
|
shutdown
|
||||||
|
exit 0
|
||||||
|
} SIGINT
|
||||||
|
|
||||||
# wait for initial prompt
|
# wait for initial prompt
|
||||||
expect "init: starting sh\r"
|
expect "init: starting sh\r"
|
||||||
expect "$ "
|
expect "$ "
|
||||||
|
|
||||||
# send command as per command line
|
# send command as per command line
|
||||||
send "$argv\r"
|
send "[lindex $argv 2]\r"
|
||||||
|
|
||||||
# wait for it to be done
|
# wait for it to be done
|
||||||
expect "$ "
|
expect "$ "
|
||||||
|
|
||||||
# send command to halt qemu (ctrl-a x)
|
# shutdown qemu properly (avoid runaways)
|
||||||
# how to do so found here:
|
shutdown
|
||||||
# https://stackoverflow.com/questions/27050473/how-to-send-ctrl-a-then-d-in-expect
|
|
||||||
send "\x01"; send "x"
|
|
||||||
|
|
||||||
# make sure to wait for it all to stop
|
|
||||||
# (without this, script was terminating before qemu quit -> bad)
|
|
||||||
interact
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user