Fix runaway bochs, pintos processes on time-outs.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 25 Jan 2005 18:13:20 +0000 (18:13 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 25 Jan 2005 18:13:20 +0000 (18:13 +0000)
grading/filesys/run-tests
grading/lib/Pintos/Grading.pm
grading/threads/run-tests
grading/userprog/run-tests
grading/vm/run-tests

index 7251cef06c412b4f2052ef63cf4feb2c92ea6e46..1b768abf84beb073ab3d15a5e4c1bf9fb7f1a0ad 100755 (executable)
@@ -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);
 }
 
index bf6099f74e9540eb8fe468ae2c44a099085b8ac2..30ac7101493b473bf96a316f0268e986f64581fb 100644 (file)
@@ -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";
index 73ab9a0697087724decac48e67dda3cb733ff70f..731499adc67e8a59f968ec71e21178fd6d56189f 100755 (executable)
@@ -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);
 }
index a13566b2ac2291a3c9afaf2e5315feb02344a689..b09bc5e200a589f2031f60494a7afbad10b6e875 100755 (executable)
@@ -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"
index 8f9e635db421bcc0c9e1b7492a9f563a7c3d63ee..fea0bfb9ccf12500642b0bc10cf888d12c6d2a47 100755 (executable)
@@ -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);
 }