diff --git a/tester/run-tests.sh b/tester/run-tests.sh index 8fb03f5..1823dd3 100755 --- a/tester/run-tests.sh +++ b/tester/run-tests.sh @@ -117,11 +117,12 @@ run_and_check () { # usage: call when args not parsed, or when help needed 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 " -v verbose" echo " -t n run only test n" echo " -c continue even after failure" + echo " -s skip pre-test initialization" echo " -d testdir run tests from testdir" return 0 } @@ -132,9 +133,10 @@ usage () { verbose=0 testdir="tests" contrunning=0 +skippre=0 specific="" -args=`getopt hvct:d: $*` +args=`getopt hvsct:d: $*` if [[ $? != 0 ]]; then usage; exit 1 fi @@ -152,6 +154,9 @@ for i; do -c) contrunning=1 shift;; + -s) + skippre=1 + shift;; -t) specific=$2 shift @@ -176,7 +181,16 @@ if [[ ! -d tests-out ]]; then fi # 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 if [[ $specific != "" ]]; then @@ -192,13 +206,3 @@ while true; do done exit 0 - - - - - - - - - - diff --git a/tester/run-xv6-command.sh b/tester/run-xv6-command.sh index e143687..6a3e3ae 100755 --- a/tester/run-xv6-command.sh +++ b/tester/run-xv6-command.sh @@ -1,29 +1,38 @@ #! /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) set timeout -1 # 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 expect "init: starting sh\r" expect "$ " # send command as per command line -send "$argv\r" +send "[lindex $argv 2]\r" # wait for it to be done expect "$ " -# send command to halt qemu (ctrl-a x) -# how to do so found here: -# 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 +# shutdown qemu properly (avoid runaways) +shutdown +