File tree Expand file tree Collapse file tree 2 files changed +35
-22
lines changed
Expand file tree Collapse file tree 2 files changed +35
-22
lines changed Original file line number Diff line number Diff line change @@ -117,11 +117,12 @@ run_and_check () {
117117
118118# usage: call when args not parsed, or when help needed
119119usage () {
120- echo " usage: run-tests.sh [-h] [-v] [-t test] [-c] [-d testdir]"
120+ echo " usage: run-tests.sh [-h] [-v] [-t test] [-c] [-s] [- d testdir]"
121121 echo " -h help message"
122122 echo " -v verbose"
123123 echo " -t n run only test n"
124124 echo " -c continue even after failure"
125+ echo " -s skip pre-test initialization"
125126 echo " -d testdir run tests from testdir"
126127 return 0
127128}
@@ -132,9 +133,10 @@ usage () {
132133verbose=0
133134testdir=" tests"
134135contrunning=0
136+ skippre=0
135137specific=" "
136138
137- args=` getopt hvct :d: $* `
139+ args=` getopt hvsct :d: $* `
138140if [[ $? != 0 ]]; then
139141 usage; exit 1
140142fi
@@ -152,6 +154,9 @@ for i; do
152154 -c)
153155 contrunning=1
154156 shift ;;
157+ -s)
158+ skippre=1
159+ shift ;;
155160 -t)
156161 specific=$2
157162 shift
@@ -176,7 +181,16 @@ if [[ ! -d tests-out ]]; then
176181fi
177182
178183# do a one-time setup step
179- # xxx
184+ if (( $skippre == 0 )) ; then
185+ if [[ -f tests/pre ]]; then
186+ builtin echo -e " \e[32mdoing one-time pre-test\e[0m (use -s to suppress)"
187+ source tests/pre
188+ if (( $? != 0 )) ; then
189+ echo " pre-test: failed"
190+ exit 1
191+ fi
192+ fi
193+ fi
180194
181195# run just one test
182196if [[ $specific != " " ]]; then
@@ -192,13 +206,3 @@ while true; do
192206done
193207
194208exit 0
195-
196-
197-
198-
199-
200-
201-
202-
203-
204-
Original file line number Diff line number Diff line change 11#! /usr/bin/env expect
22
3+ proc shutdown {} {
4+ # send command to halt qemu (ctrl-a x)
5+ # https://stackoverflow.com/questions/27050473/how-to-send-ctrl-a-then-d-in-expect
6+ send " \x01" ; send " x"
7+ # make sure to wait for it all to stop
8+ # (without this, script was terminating before qemu quit -> bad)
9+ expect eof
10+ }
11+
312# turn off timeout (perhaps make this flexible later)
413set timeout -1
514
615# build and launch xv6 on qemu
7- spawn make qemu-nox
16+ spawn make [lindex $argv 0] -f [lindex $argv 1] qemu-nox
17+
18+ trap {
19+ shutdown
20+ exit 0
21+ } SIGINT
822
923# wait for initial prompt
1024expect " init: starting sh\r"
1125expect " $ "
1226
1327# send command as per command line
14- send " $argv \r"
28+ send " [lindex $argv 2] \r"
1529
1630# wait for it to be done
1731expect " $ "
1832
19- # send command to halt qemu (ctrl-a x)
20- # how to do so found here:
21- # https://stackoverflow.com/questions/27050473/how-to-send-ctrl-a-then-d-in-expect
22- send " \x01" ; send " x"
33+ # shutdown qemu properly (avoid runaways)
34+ shutdown
2335
24- # make sure to wait for it all to stop
25- # (without this, script was terminating before qemu quit -> bad)
26- interact
2736
2837
2938
You can’t perform that action at this time.
0 commit comments