Use standard POSIX "ustar" format for the scratch disk.
[pintos-anon] / src / tests / tests.pm
index 179f110a9f986d75481f18ab950545f0e18c242e..4599cb98fe49d7627173d182f48ce2ef072f03ab 100644 (file)
@@ -12,6 +12,16 @@ our ($test, $src_dir) = @ARGV;
 
 my ($msg_file) = tempfile ();
 select ($msg_file);
+
+our (@prereq_tests) = ();
+if ($test =~ /^(.*)-persistence$/) {
+    push (@prereq_tests, $1);
+}
+for my $prereq_test (@prereq_tests) {
+    my (@result) = read_text_file ("$prereq_test.result");
+    fail "Prerequisite test $prereq_test failed.\n" if $result[0] ne 'PASS';
+}
+
 \f
 # Generic testing.
 
@@ -235,7 +245,8 @@ sub compare_output {
 #         recursively.
 sub check_archive {
     my ($expected_hier) = @_;
-    my (@output) = read_text_file ("$test.get-output");
+
+    my (@output) = read_text_file ("$test.output");
     common_checks ("file system extraction run", @output);
 
     @output = get_core_output ("file system extraction run", @output);
@@ -244,11 +255,12 @@ sub check_archive {
 
     my ($test_base_name) = $test;
     $test_base_name =~ s%.*/%%;
-    $expected_hier->{$test_base_name} = $test;
+    $test_base_name =~ s%-persistence$%%;
+    $expected_hier->{$test_base_name} = $prereq_tests[0];
     $expected_hier->{'tar'} = 'tests/filesys/extended/tar';
 
     my (%expected) = normalize_fs (flatten_hierarchy ($expected_hier, ""));
-    my (%actual) = read_tar ("$test.tar");
+    my (%actual) = read_tar ("$prereq_tests[0].tar");
 
     my ($errors) = 0;
     foreach my $name (sort keys %expected) {
@@ -273,7 +285,7 @@ sub check_archive {
                my ($esc_name) = $name;
                $esc_name =~ s/[^[:print:]]/./g;
                print <<EOF;
-$esc_name exists in the file system but should not.  (The expected name
+$esc_name exists in the file system but should not.  (The name
 of this file contains unusual characters that were printed as `.'.)
 EOF
            }
@@ -444,6 +456,7 @@ sub print_fs {
        }
        print "\n";
     }
+    print "(empty)\n" if !@_;
 }
 
 # normalize_fs (%FS)
@@ -548,12 +561,15 @@ sub read_tar {
        $size = 0 if $typeflag eq '5';
 
        # Store content.
+       $name =~ s%^(/|\./|\.\./)*%%;   # Strip leading "/", "./", "../".
+       $name = '' if $name eq '.' || $name eq '..';
        if (exists $content{$name}) {
            fail "$archive: contains multiple entries for $name\n";
        }
        if ($typeflag eq '5') {
-           $content{$name} = 'directory';
+           $content{$name} = 'directory' if $name ne '';
        } else {
+           fail "$archive: contains file with empty name\n" if $name eq '';
            my ($position) = sysseek (ARCHIVE, 0, SEEK_CUR);
            $content{$name} = [$archive, $position, $size];
            sysseek (ARCHIVE, int (($size + 511) / 512) * 512, SEEK_CUR);