From: Ben Pfaff Date: Tue, 25 Jan 2005 18:13:20 +0000 (+0000) Subject: Fix runaway bochs, pintos processes on time-outs. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2969f4df6a95b37e05ad6aa562ae82206b646eb0;p=pintos-anon Fix runaway bochs, pintos processes on time-outs. --- diff --git a/grading/filesys/run-tests b/grading/filesys/run-tests index 7251cef..1b768ab 100755 --- a/grading/filesys/run-tests +++ b/grading/filesys/run-tests @@ -64,13 +64,12 @@ sub run_test { DIE => "failed to create swap disk"); # Format disk, install test. - my ($pintos_base_cmd) = - "pintos " - . "--os-disk=pintos/src/$hw/build/os.dsk " - . "--fs-disk=output/$test/fs.dsk " - . "--swap-disk=output/$test/swap.dsk " - . "-v"; - $result = run_pintos ("$pintos_base_cmd put -f $GRADES_DIR/$test $test", + my (@base_opts) = ("--os-disk=pintos/src/$hw/build/os.dsk", + "--fs-disk=output/$test/fs.dsk", + "--swap-disk=output/$test/swap.dsk", + "-v"); + $result = run_pintos ([@base_opts, + "put", "-f", "$GRADES_DIR/$test", $test], LOG => "$test/put", TIMEOUT => 60); return $result if $result ne 'ok'; @@ -79,13 +78,13 @@ sub run_test { push (@extra_files, "child-syn-wrt") if $test eq 'syn-write'; push (@extra_files, "child-syn-rw") if $test eq 'syn-rw'; for my $fn (@extra_files) { - $result = run_pintos ("$pintos_base_cmd put $GRADES_DIR/$fn $fn", + $result = run_pintos ([@base_opts, "put", "$GRADES_DIR/$fn", $fn], LOG => "$test/put-$fn", TIMEOUT => 60); return "Error running `put $fn': $result" if $result ne 'ok'; } # Run. - return run_pintos ("$pintos_base_cmd run -q -ex \"$test\"", + return run_pintos ([@base_opts, "run", "-q", "-ex", $test], LOG => "$test/run", TIMEOUT => 120); } diff --git a/grading/lib/Pintos/Grading.pm b/grading/lib/Pintos/Grading.pm index bf6099f..30ac710 100644 --- a/grading/lib/Pintos/Grading.pm +++ b/grading/lib/Pintos/Grading.pm @@ -316,7 +316,13 @@ sub xsystem { open (STDOUT, ">output/$log.out"); open (STDERR, ">output/$log.err"); } - exec ($command); + chdir $options{CHDIR} or die "$options{CHDIR}: chdir: $!\n" + if defined ($options{CHDIR}); + if (!defined ($options{EXEC})) { + exec ($command); + } else { + exec (@{$options{EXEC}}); + } exit (-1); } waitpid ($pid, 0); @@ -399,7 +405,8 @@ sub get_test_result { sub run_pintos { my ($cmd_line, %args) = @_; - my ($retval) = xsystem ($cmd_line, %args); + unshift (@$cmd_line, 'pintos'); + my ($retval) = xsystem (join (' ', @$cmd_line), %args, EXEC => $cmd_line); return 'ok' if $retval eq 'ok'; if ($retval eq 'timeout') { my ($msg) = "Timed out after $args{TIMEOUT} seconds"; diff --git a/grading/threads/run-tests b/grading/threads/run-tests index 73ab9a0..731499a 100755 --- a/grading/threads/run-tests +++ b/grading/threads/run-tests @@ -95,7 +95,8 @@ sub run_test { # Run. my ($timeout) = $test !~ /^mlfqs/ ? 10 : 600; - return run_pintos ("cd pintos/src/threads/build && pintos -v run -q", + return run_pintos (["-v", "run", "-q"], + CHDIR => "pintos/src/threads/build", LOG => "$test/run", TIMEOUT => $timeout); } diff --git a/grading/userprog/run-tests b/grading/userprog/run-tests index a13566b..b09bc5e 100755 --- a/grading/userprog/run-tests +++ b/grading/userprog/run-tests @@ -82,10 +82,9 @@ sub run_test { # Run. my ($timeout) = $test !~ /^multi-/ ? 10 : 600; - my ($result) = run_pintos ("pintos " - . "--os-disk=pintos/src/userprog/build/os.dsk " - . "--fs-disk=output/$test/fs.dsk " - . "-v run -q -ex \"$test$args\"", + my ($result) = run_pintos (["--os-disk=pintos/src/userprog/build/os.dsk", + "--fs-disk=output/$test/fs.dsk", + "-v", "run", "-q", "-ex", "$test$args"], LOG => "$test/run", TIMEOUT => $timeout); rename "output/$test/fs.dsk", "output/$test/fs.dsk.keep" @@ -164,10 +163,9 @@ sub grade_multi_oom { sub get_file { my ($guest_fn, $host_fn) = @_; - my ($result) = run_pintos ("pintos " - . "--os-disk=pintos/src/userprog/build/os.dsk " - . "--fs-disk=output/$test/fs.dsk.keep " - . "-v get $guest_fn $host_fn", + my ($result) = run_pintos (["--os-disk=pintos/src/userprog/build/os.dsk", + "--fs-disk=output/$test/fs.dsk.keep", + "-v", "get", "$guest_fn", "$host_fn"], LOG => "$test/get-$guest_fn", TIMEOUT => 10); die "`pintos get $guest_fn' failed - $result\n" diff --git a/grading/vm/run-tests b/grading/vm/run-tests index 8f9e635..fea0bfb 100755 --- a/grading/vm/run-tests +++ b/grading/vm/run-tests @@ -52,11 +52,10 @@ sub run_test { DIE => "failed to create swap disk"); # Run. - return run_pintos ("pintos " - . "--os-disk=pintos/src/vm/build/os.dsk " - . "--fs-disk=output/$test/fs.dsk " - . "--swap-disk=output/$test/swap.dsk " - . "-v run -q -ex \"$test\"", + return run_pintos (["--os-disk=pintos/src/vm/build/os.dsk", + "--fs-disk=output/$test/fs.dsk", + "--swap-disk=output/$test/swap.dsk", + "-v", "run", "-q", "-ex", "$test"], LOG => "$test/run", TIMEOUT => 600); }