Improve run-tests to accept more output code formats.
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 4 Nov 2004 01:22:23 +0000 (01:22 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 4 Nov 2004 01:22:23 +0000 (01:22 +0000)
Fix some tests.

grading/userprog/.cvsignore
grading/userprog/exec-missing.exp
grading/userprog/join-bad-pid.exp
grading/userprog/join-twice.c
grading/userprog/join-twice.exp
grading/userprog/mkmf
grading/userprog/prep-disk
grading/userprog/run-tests

index 73d1273bd0d8c68e382a1564159f942a19d67e87..602fcbdd0b8e687dfd290cca2221426a035b6f5d 100644 (file)
@@ -1,2 +1,58 @@
+# Automatically generated by mkmf - do not modify!
 *.d
 *.dsk
+*.o
+args-argc
+args-argv0
+args-argvn
+args-single
+args-multiple
+args-dbl-space
+sc-bad-sp
+sc-bad-arg
+sc-boundary
+halt
+exit
+create-normal
+create-empty
+create-null
+create-bad-ptr
+create-long
+create-exists
+create-bound
+open-normal
+open-missing
+open-boundary
+open-empty
+open-null
+open-bad-ptr
+open-twice
+close-normal
+close-twice
+close-stdin
+close-stdout
+close-bad-fd
+read-normal
+read-bad-ptr
+read-boundary
+read-zero
+read-stdout
+read-bad-fd
+write-normal
+write-bad-ptr
+write-boundary
+write-zero
+write-stdin
+write-bad-fd
+exec-once
+exec-arg
+exec-multiple
+exec-missing
+exec-bad-ptr
+join-simple
+join-twice
+join-killed
+join-bad-pid
+multi-recurse
+multi-oom
+multi-child-fd
index 7334b9ed27cb7a206109087d4b40e319fcfbcc48..56670408890eaf4fd17e6759fc2710ce15c61bbe 100644 (file)
@@ -1,4 +1,12 @@
 (exec-missing) begin
+load: no-such-file: open failed
+(exec-missing) exec("no-such-file"): -1
+(exec-missing) end
+exec-missing: exit(0)
+--OR--
+(exec-missing) begin
+load: no-such-file: open failed
+no-such-file: exit(-1)
 (exec-missing) exec("no-such-file"): -1
 (exec-missing) end
 exec-missing: exit(0)
index 044648235a86057ebb674da9110cbf2a4436e3e9..2f7f5eeee86b811b3bb32e72ba4f2c0839541c99 100644 (file)
@@ -1,4 +1,6 @@
-(join-simple) begin
-(join-simple) join(exec()) = 81
-(join-simple) end
-join-simple: exit(0)
+(join-bad-pid) begin
+(join-bad-pid) end
+join-bad-pid: exit(0)
+--OR--
+(join-bad-pid) begin
+join-bad-pid: exit(-1)
index 10ccb22050420b4a7121925166dbe66586011bc9..2a80ad78f11d349b27b233c2756eebbd34d07a30 100644 (file)
@@ -6,7 +6,7 @@ main (void)
 {
   pid_t child;
   printf ("(join-twice) begin\n");
-  child = exec ("child-twice");
+  child = exec ("child-simple");
   printf ("(join-twice) join(exec()) = %d\n", join (child));
   join (child);
   printf ("(join-twice) end\n");
index 71f62234e48d5b247d80b9dc16cb37c172bf54e0..ffb57ea68e4054dc37bd40dc5bc63f3b3760bb23 100644 (file)
@@ -1,6 +1,6 @@
 (join-twice) begin
-(child-twice) run
-child-twice: exit(81)
+(child-simple) run
+child-simple: exit(81)
 (join-twice) join(exec()) = 81
 (join-twice) end
 join-twice: exit(0)
index a45ee56c098bd11dcc4166a91c379f69f32c7166..7cfeae83828ab5cf4393213edbd2b1b77110f91a 100755 (executable)
@@ -46,3 +46,12 @@ while (<MAKEBASE>) {
 }
 close (MAKEBASE);
 
+open (CVSIGNORE, ">.cvsignore");
+print CVSIGNORE <<EOF;
+# Automatically generated by mkmf - do not modify!
+*.d
+*.dsk
+*.o
+EOF
+print CVSIGNORE join ("\n", @tests), "\n";
+close (CVSIGNORE);
index 611fdcce55767142179d6a67dfc5fb728320e00d..1d34e5fb1a340ecaac39c084dc3f7c4abeafce8f 100755 (executable)
@@ -42,9 +42,13 @@ put_file ("sample.txt")
                 read-normal read-bad-ptr read-boundary read-zero
                 write-normal write-bad-ptr write-boundary write-zero
                 multi-child-fd));
-put_file ("child-simple") if $test eq 'exec-once' or $test eq 'exec-multiple';
+put_file ("child-simple")
+    if grep ($_ eq $test,
+            qw (exec-once exec-multiple
+                join-simple join-twice));
 put_file ("child-arg") if $test eq 'exec-arg';
 put_file ("child-close") if $test eq 'multi-child-fd';
+put_file ("child-bad") if $test eq 'join-killed';
 
 sub put_file {
     my ($fn) = @_;
index e2587c20a44e2f6ddf2fb8dce94d5910b1e2ccab..8faecaa7143b32f1813ecdf296e8d709942875f8 100755 (executable)
@@ -51,6 +51,7 @@ sub usage {
             write-normal write-bad-ptr write-boundary write-zero write-stdin
             write-bad-fd
             exec-once exec-arg exec-multiple exec-missing exec-bad-ptr
+            join-simple join-twice join-killed join-bad-pid
             multi-recurse multi-oom multi-child-fd
             ) unless @TESTS > 0;
 
@@ -347,16 +348,28 @@ sub grade_multi_oom {
        shift @output;
     }
     die "Only $n child processes started.\n" if $n < 15;
+
+    # There could be a death notice for a process that didn't get
+    # fully loaded, and/or notices from the loader.
+    while (@output > 0
+          && ($output[0] =~ /^\(multi-oom\) end $n$/
+              || $output[0] =~ /^load: /)) {
+       shift @output;
+    }
+
     while (--$n >= 0) {
        die "Output ended unexpectedly before process $n finished.\n"
            if @output < 2;
+
+       local ($_);
+       chomp ($_ = shift @output);
+       die "Found '$_' expecting 'end' message.\n" if !/^\(multi-oom\) end/;
        die "Child process $n ended out of order.\n"
-           if $output[0] !~ /^\(multi-oom\) end $n$/;
-       shift @output;
+           if !/^\(multi-oom\) end $n$/;
 
-       die "Child process $n didn't print proper exit message.\n"
-           if $output[0] !~ /^multi-oom: exit\($n\)$/;
-       shift @output;
+       chomp ($_ = shift @output);
+       die "Kernel didn't print proper exit message for process $n.\n"
+           if !/^multi-oom: exit\($n\)$/;
     }
     die "Spurious output at end: '$output[0]'.\n" if @output;
 }
@@ -446,9 +459,18 @@ sub fix_exit_codes {
     my (@output) = @_;
 
     # Fix up lines that look like exit codes.
+    # Exit codes are supposed to be printed in the form "process: exit(code)"
+    # but people get unfortunately creative with it.
     for my $i (0...$#output) {
-       if (my ($process, $code)
-           = $output[$i] =~ /^([-a-zA-Z0-9 ]+):.*[ \(](-?\d+)\b\)?$/) {
+       local ($_) = $output[$i];
+       
+       my ($process, $code);
+       if ((($process, $code) = /^([-a-zA-Z0-9 ]+):.*[ \(](-?\d+)\b\)?$/)
+           || (($process, $code) = /^([-a-zA-Z0-9 ]+) exit\((-?\d+)\)$/)
+           || (($process, $code)
+               = /^([-a-zA-Z0-9 ]+) \(.*\): exit\((-?\d+)\)$/)
+           || (($process, $code) = /^([-a-zA-Z0-9 ]+):\( (-?\d+) \) $/)
+) {
            $process = substr ($process, 0, 15);
            $process =~ s/\s.*//;
            $output[$i] = "$process: exit($code)\n";
@@ -510,7 +532,8 @@ sub compare_output {
 
        $details .= "Differences in `diff -u' format:\n";
        $details .= join ('', @diff);
-       $details .= "(This is considered a `fuzzy match'.)\n" if $fuzzy_match;
+       $details .= "(This is considered a `fuzzy match'.)\n"
+           if !$not_fuzzy_match;
     }
 
     $details{$test} = $details;