From 39e2b81b7bb61f390e5bb0a3972f943ef133b7b9 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 9 Jan 2005 00:31:45 +0000 Subject: [PATCH] When running a "test" or "assemble" target, run-tests now returns zero if all tests succeeded or nonzero if at least one failed. --- grading/filesys/run-tests | 4 ++-- grading/lib/Pintos/Grading.pm | 7 +++++++ grading/threads/run-tests | 4 ++-- grading/userprog/run-tests | 12 ++++++++++-- grading/vm/run-tests | 4 ++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/grading/filesys/run-tests b/grading/filesys/run-tests index 143ab4a..7251cef 100755 --- a/grading/filesys/run-tests +++ b/grading/filesys/run-tests @@ -40,12 +40,12 @@ extract_sources (); exit if $action eq 'extract'; build (); -exit if $action eq 'build'; +exit success () if $action eq 'build'; run_and_grade_tests (); write_grades (); write_details (); -exit if $action eq 'test'; +exit success () if $action eq 'test'; assemble_final_grade (); exit if $action eq 'assemble'; diff --git a/grading/lib/Pintos/Grading.pm b/grading/lib/Pintos/Grading.pm index c2072a4..7e5ec67 100644 --- a/grading/lib/Pintos/Grading.pm +++ b/grading/lib/Pintos/Grading.pm @@ -832,5 +832,12 @@ sub file_contains { close (FILE); return $equal; } + +sub success { + for my $test (@TESTS) { + return 1 if !defined ($result{$test}) || $result{$test} ne 'ok'; + } + return 0; +} 1; diff --git a/grading/threads/run-tests b/grading/threads/run-tests index 4199d94..73ab9a0 100755 --- a/grading/threads/run-tests +++ b/grading/threads/run-tests @@ -44,10 +44,10 @@ if (defined ($result{'mlfqs-on'}) && defined ($result{'mlfqs-off'})) { } write_grades (); write_details (); -exit if $action eq 'test'; +exit success () if $action eq 'test'; assemble_final_grade (); -exit if $action eq 'assemble'; +exit success () if $action eq 'assemble'; die "Don't know how to '$action'"; diff --git a/grading/userprog/run-tests b/grading/userprog/run-tests index 9384eba..ec185ee 100755 --- a/grading/userprog/run-tests +++ b/grading/userprog/run-tests @@ -20,6 +20,14 @@ our ($test); our (%extra); our ($action); +if ($#ARGV == 0 && $ARGV[0] eq 'null') { + @TESTS = ('null'); + extract_sources (); + build (); + run_and_grade_tests (); + exit success (); +} + parse_cmd_line qw (args-argc args-argv0 args-argvn args-single args-multiple args-dbl-space sc-bad-sp sc-bad-arg sc-boundary @@ -49,10 +57,10 @@ exit if $action eq 'build'; run_and_grade_tests (); write_grades (); write_details (); -exit if $action eq 'test'; +exit success () if $action eq 'test'; assemble_final_grade (); -exit if $action eq 'assemble'; +exit success () if $action eq 'assemble'; die "Don't know how to '$action'"; diff --git a/grading/vm/run-tests b/grading/vm/run-tests index 23fec90..8f9e635 100755 --- a/grading/vm/run-tests +++ b/grading/vm/run-tests @@ -35,10 +35,10 @@ exit if $action eq 'build'; run_and_grade_tests (); write_grades (); write_details (); -exit if $action eq 'test'; +exit success () if $action eq 'test'; assemble_final_grade (); -exit if $action eq 'assemble'; +exit success () if $action eq 'assemble'; die "Don't know how to '$action'"; -- 2.30.2