From: Ben Pfaff Date: Mon, 22 Nov 2004 23:37:11 +0000 (+0000) Subject: Fix treatment of timeouts in run-tests and pintos. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=892590a6b5883b307fe6b3c15c91a9c1d9c014db;p=pintos-anon Fix treatment of timeouts in run-tests and pintos. --- diff --git a/grading/vm/run-tests b/grading/vm/run-tests index 42e198b..85164aa 100755 --- a/grading/vm/run-tests +++ b/grading/vm/run-tests @@ -265,7 +265,8 @@ sub really_run_test { . "--swap-disk=output/$test/swap.dsk " . "-v run -q -ex \"$test$testargs\"", LOG => "$test/run", - TIMEOUT => $timeout) + TIMEOUT => $timeout, + EXPECT => 1) or return "Bochs error"; return "ok"; @@ -683,9 +684,7 @@ sub xsystem { die "fork: $!\n" if !defined $pid; if (!$pid) { if (defined $log) { - close STDOUT; open (STDOUT, ">output/$log.out"); - close STDERR; open (STDERR, ">output/$log.err"); } exec ($command); @@ -698,7 +697,7 @@ sub xsystem { if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors print "Timed out $pid.\n"; - print "not killed\n" if !kill ('SIGTERM', $pid); + kill ('SIGTERM', $pid); $status = 0; } @@ -708,11 +707,14 @@ sub xsystem { print "Child terminated with signal $signal\n"; } - unlink ("output/$log.err") if defined ($log) && $status == 0; + my ($expected_exit) = !defined ($options{EXPECT}) ? 0 : $options{EXPECT}; + my ($ok) = WIFEXITED ($status) && WEXITSTATUS ($status) == $expected_exit; + + unlink ("output/$log.err") if defined ($log) && $ok; die $options{DIE} if $status != 0 && defined $options{DIE}; - return $status == 0; + return $ok; } sub snarf { diff --git a/src/utils/pintos b/src/utils/pintos index e513ab1..4ce2d85 100755 --- a/src/utils/pintos +++ b/src/utils/pintos @@ -234,8 +234,8 @@ sub run_vm { my (@cmd) = ($bin, '-q'); push (@cmd, '-j', $jitter) if defined $jitter; - print join (' ', @_), "\n"; - exec (@_); + print join (' ', @cmd), "\n"; + exec (@cmd); } elsif ($sim eq 'qemu') { print "warning: qemu doesn't support --terminal\n" if $vga eq 'terminal';