X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftests%2Ftests.pm;h=7d0777c4ff24b6d8b9861cd636731ca526f19a04;hb=edd39beb4deffa73f4ff0c4609ec437d357a5ea6;hp=d085df1c98de59d7430a7cfc3dc9caa571f5672f;hpb=615bf3b3d2a8573ed6fb9ddc0055745e163ac999;p=pintos-anon diff --git a/src/tests/tests.pm b/src/tests/tests.pm index d085df1..7d0777c 100644 --- a/src/tests/tests.pm +++ b/src/tests/tests.pm @@ -1,6 +1,7 @@ use strict; use warnings; -use Algorithm::Diff; +use tests::Algorithm::Diff; +use File::Temp 'tempfile'; sub fail; sub pass; @@ -9,9 +10,8 @@ die if @ARGV != 2; our ($test, $src_dir) = @ARGV; our ($src_stem) = "$src_dir/$test"; -our ($messages) = ""; -open (MESSAGES, '>', \$messages); -select (MESSAGES); +my ($msg_file) = tempfile (); +select ($msg_file); sub check_expected { my ($expected) = pop @_; @@ -80,12 +80,6 @@ sub check_for_keyword { $kw_line =~ s/^\([^\)]+\)\s+//; print "$kw_line\n"; - # Append output, eliminating uninteresting header and trailer info - # if possible. - my (@core) = get_core_output (@output); - @output = @core if @core; - print "Program output:\n\n" . join ('', map ("$_\n", @output)); - fail; } @@ -96,18 +90,9 @@ sub check_for_triple_fault { print < 1; - } - fail; } @@ -133,13 +118,13 @@ sub compare_output { } die "unknown option " . (keys (%options))[0] . "\n" if %options; - my ($msg) = "Actual output:\n" . join ('', map (" $_\n", @output)); + my ($msg); # Compare actual output against each allowed output. foreach my $exp_string (@$expected) { my (@expected) = split ("\n", $exp_string); - $msg .= "\nAcceptable output:\n"; + $msg .= "Acceptable output:\n"; $msg .= join ('', map (" $_\n", @expected)); # Check whether actual and expected match. @@ -184,6 +169,13 @@ sub pass { sub finish { my ($verdict, @rest) = @_; + my ($messages) = ""; + seek ($msg_file, 0, 0); + while (<$msg_file>) { + $messages .= $_; + } + close ($msg_file); + my ($result_fn) = "$test.result"; open (RESULT, '>', $result_fn) or die "$result_fn: create: $!\n"; print RESULT "$verdict\n", $messages, @rest;