Suggested by Godmar Back.
PROGS = $(foreach subdir,$(TEST_SUBDIRS),$($(subdir)_PROGS))
TESTS = $(foreach subdir,$(TEST_SUBDIRS),$($(subdir)_TESTS))
+EXTRA_GRADES = $(foreach subdir,$(TEST_SUBDIRS),$($(subdir)_EXTRA_GRADES))
-OUTPUTS = $(addsuffix .output,$(TESTS))
-ERRORS = $(addsuffix .errors,$(TESTS))
-RESULTS = $(addsuffix .result,$(TESTS))
+OUTPUTS = $(addsuffix .output,$(TESTS) $(EXTRA_GRADES))
+ERRORS = $(addsuffix .errors,$(TESTS) $(EXTRA_GRADES))
+RESULTS = $(addsuffix .result,$(TESTS) $(EXTRA_GRADES))
ifdef PROGS
include ../../Makefile.userprog
fi
results: $(RESULTS)
- @for d in $(TESTS); do \
+ @for d in $(TESTS) $(EXTRA_GRADES); do \
if echo PASS | cmp -s $$d.result -; then \
echo "pass $$d"; \
else \
# all the previous functionality should work too. It's not too easy
# to screw it up, thus the emphasis.
-# 75% for file system.
-33.3% tests/filesys/extended/Rubric.functionality
+# 50% for extended file system features.
+16.7% tests/filesys/extended/Rubric.functionality
16.7% tests/filesys/extended/Rubric.robustness
+16.6% tests/filesys/extended/Rubric.persistence
+
+# 25% to not break the provided file system features.
25% tests/filesys/base/Rubric
# 25% for the rest.
# all the previous functionality should work too. It's not too easy
# to screw it up, thus the emphasis.
-# 75% for file system.
-33.3% tests/filesys/extended/Rubric.functionality
+# 50% for extended file system features.
+16.7% tests/filesys/extended/Rubric.functionality
16.7% tests/filesys/extended/Rubric.robustness
+16.6% tests/filesys/extended/Rubric.persistence
+
+# 25% to not break the provided file system features.
25% tests/filesys/base/Rubric
# 25% for the rest.
# -*- makefile -*-
-tests/filesys/extended_TESTS = $(addprefix \
-tests/filesys/extended/,dir-empty-name dir-mk-tree dir-mkdir dir-open \
+raw_tests = dir-empty-name dir-mk-tree dir-mkdir dir-open \
dir-over-file dir-rm-cwd dir-rm-parent dir-rm-root dir-rm-tree \
dir-rmdir dir-under-file dir-vine grow-create grow-dir-lg \
grow-file-size grow-root-lg grow-root-sm grow-seq-lg grow-seq-sm \
-grow-sparse grow-tell grow-two-files syn-rw)
+grow-sparse grow-tell grow-two-files syn-rw
-tests/filesys/extended_PROGS = $(tests/filesys/extended_TESTS) \
+tests/filesys/extended_TESTS = $(patsubst %,tests/filesys/extended/%,$(raw_tests))
+tests/filesys/extended_EXTRA_GRADES = $(patsubst %,tests/filesys/extended/%-persistence,$(raw_tests))
+
+tests/filesys/extended_PROGS = $(tests/filesys/extended_TESTS) \
tests/filesys/extended/child-syn-rw tests/filesys/extended/tar
$(foreach prog,$(tests/filesys/extended_PROGS), \
tests/filesys/extended/syn-rw_PUTFILES += tests/filesys/extended/child-syn-rw
-
GETTIMEOUT = 60
GETCMD = pintos -v -k -T $(GETTIMEOUT)
GETCMD += $(KERNELFLAGS)
GETCMD += run 'tar fs.tar /'
GETCMD += < /dev/null
-GETCMD += 2> $(TEST).get-errors $(if $(VERBOSE),|tee,>) $(TEST).get-output
+GETCMD += 2> $(TEST)-persistence.errors $(if $(VERBOSE),|tee,>) $(TEST)-persistence.output
tests/filesys/extended/%.output: os.dsk
rm -f tmp.dsk
$(TESTCMD)
$(GETCMD)
rm -f tmp.dsk
+$(foreach raw_test,$(raw_tests),$(eval tests/filesys/extended/$(raw_test)-persistence.output: tests/filesys/extended/$(raw_test).output; ))
+$(foreach raw_test,$(raw_tests),$(eval tests/filesys/extended/$(raw_test)-persistence.result: tests/filesys/extended/$(raw_test).result))
TARS = $(addsuffix .tar,$(tests/filesys/extended_TESTS))
-GET_OUTPUTS = $(addsuffix .get-output,$(tests/filesys/extended_TESTS))
-GET_ERRORS = $(addsuffix .get-errors,$(tests/filesys/extended_TESTS))
clean::
- rm -f $(TARS) $(GET_OUTPUTS) $(GET_ERRORS)
+ rm -f $(TARS)
+ rm -f tests/filesys/extended/can-rmdir-cwd
--- /dev/null
+Persistence of file system:
+1 dir-empty-name-persistence
+1 dir-mk-tree-persistence
+1 dir-mkdir-persistence
+1 dir-open-persistence
+1 dir-over-file-persistence
+1 dir-rm-cwd-persistence
+1 dir-rm-parent-persistence
+1 dir-rm-root-persistence
+1 dir-rm-tree-persistence
+1 dir-rmdir-persistence
+1 dir-under-file-persistence
+1 dir-vine-persistence
+1 grow-create-persistence
+1 grow-dir-lg-persistence
+1 grow-file-size-persistence
+1 grow-root-lg-persistence
+1 grow-root-sm-persistence
+1 grow-seq-lg-persistence
+1 grow-seq-sm-persistence
+1 grow-sparse-persistence
+1 grow-tell-persistence
+1 grow-two-files-persistence
+1 syn-rw-persistence
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({});
+pass;
(dir-empty-name) mkdir "" (must return false)
(dir-empty-name) end
EOF
-check_archive ({});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+my ($tree);
+for my $a (0...3) {
+ for my $b (0...2) {
+ for my $c (0...2) {
+ for my $d (0...3) {
+ $tree->{$a}{$b}{$c}{$d} = [''];
+ }
+ }
+ }
+}
+check_archive ($tree);
+pass;
(dir-mk-tree) close "/0/2/0/3"
(dir-mk-tree) end
EOF
-my ($tree);
-for my $a (0...3) {
- for my $b (0...2) {
- for my $c (0...2) {
- for my $d (0...3) {
- $tree->{$a}{$b}{$c}{$d} = [''];
- }
- }
- }
-}
-check_archive ($tree);
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({'a' => {'b' => ["\0" x 512]}});
+pass;
(dir-mkdir) open "b"
(dir-mkdir) end
EOF
-check_archive ({'a' => {'b' => ["\0" x 512]}});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({"xyzzy" => {}});
+pass;
(dir-open) write "xyzzy"
dir-open: exit(-1)
EOF
-check_archive ({"xyzzy" => {}});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({"abc" => {}});
+pass;
(dir-over-file) create "abc" (must return false)
(dir-over-file) end
EOF
-check_archive ({"abc" => {}});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+my ($cwd_removable) = read_text_file ("tests/filesys/extended/can-rmdir-cwd");
+$cwd_removable eq 'YES' || $cwd_removable eq 'NO' or die;
+check_archive ($cwd_removable eq 'YES' ? {} : {"a" => {}});
+pass;
(dir-rm-cwd) verify "/a" is empty
(dir-rm-cwd) end
EOF
-
-check_archive ($cwd_removable eq 'YES' ? {} : {"a" => {}});
+open (CAN_RMDIR_CWD, ">tests/filesys/extended/can-rmdir-cwd")
+ or die "tests/filesys/extended/can-rmdir-cwd: create: $!\n";
+print CAN_RMDIR_CWD "$cwd_removable";
+close (CAN_RMDIR_CWD);
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({"a" => {"b" => {}}});
+pass;
(dir-rm-parent) remove "/a" (must fail)
(dir-rm-parent) end
EOF
-check_archive ({"a" => {"b" => {}}});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({"a" => ["\0" x 243]});
+pass;
(dir-rm-root) create "/a"
(dir-rm-root) end
EOF
-check_archive ({"a" => ["\0" x 243]});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({});
+pass;
(dir-rm-tree) open "/3/0/2/0" (must return -1)
(dir-rm-tree) end
EOF
-check_archive ({});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({});
+pass;
(dir-rmdir) chdir "a" (must return false)
(dir-rmdir) end
EOF
-check_archive ({});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({"abc" => ['']});
+pass;
(dir-under-file) mkdir "abc" (must return false)
(dir-under-file) end
EOF
-check_archive ({"abc" => ['']});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+# The archive should look like this:
+#
+# 40642 dir-vine
+# 42479 tar
+# 0 start
+# 11 start/file0
+# 0 start/dir0
+# 11 start/dir0/file1
+# 0 start/dir0/dir1
+# 11 start/dir0/dir1/file2
+# 0 start/dir0/dir1/dir2
+# 11 start/dir0/dir1/dir2/file3
+# 0 start/dir0/dir1/dir2/dir3
+# 11 start/dir0/dir1/dir2/dir3/file4
+# 0 start/dir0/dir1/dir2/dir3/dir4
+# 11 start/dir0/dir1/dir2/dir3/dir4/file5
+# 0 start/dir0/dir1/dir2/dir3/dir4/dir5
+# 11 start/dir0/dir1/dir2/dir3/dir4/dir5/file6
+# 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6
+# 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/file7
+# 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7
+# 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file8
+# 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8
+# 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file9
+# 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9
+my ($dir) = {};
+my ($root) = {"start" => $dir};
+for (my ($i) = 0; $i < 10; $i++) {
+ $dir->{"file$i"} = ["contents $i\n"];
+ $dir = $dir->{"dir$i"} = {};
+}
+check_archive ($root);
+pass;
(dir-vine) removing all but top 10 levels of files and directories...
(dir-vine) end
EOF
-
-# The archive should look like this:
-#
-# 40642 dir-vine
-# 42479 tar
-# 0 start
-# 11 start/file0
-# 0 start/dir0
-# 11 start/dir0/file1
-# 0 start/dir0/dir1
-# 11 start/dir0/dir1/file2
-# 0 start/dir0/dir1/dir2
-# 11 start/dir0/dir1/dir2/file3
-# 0 start/dir0/dir1/dir2/dir3
-# 11 start/dir0/dir1/dir2/dir3/file4
-# 0 start/dir0/dir1/dir2/dir3/dir4
-# 11 start/dir0/dir1/dir2/dir3/dir4/file5
-# 0 start/dir0/dir1/dir2/dir3/dir4/dir5
-# 11 start/dir0/dir1/dir2/dir3/dir4/dir5/file6
-# 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6
-# 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/file7
-# 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7
-# 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file8
-# 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8
-# 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file9
-# 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9
-my ($dir) = {};
-my ($root) = {"start" => $dir};
-for (my ($i) = 0; $i < 10; $i++) {
- $dir->{"file$i"} = ["contents $i\n"];
- $dir = $dir->{"dir$i"} = {};
-}
-check_archive ($root);
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({"blargle" => ['']});
+pass;
(grow-create) close "blargle"
(grow-create) end
EOF
-check_archive ({"blargle" => ['']});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+my ($fs);
+$fs->{'x'}{"file$_"} = [random_bytes (512)] foreach 0...49;
+check_archive ($fs);
+pass;
(grow-dir-lg) creating and checking "/x/file49"
(grow-dir-lg) end
EOF
-my ($fs);
-$fs->{'x'}{"file$_"} = [random_bytes (512)] foreach 0...49;
-check_archive ($fs);
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+check_archive ({"testfile" => [random_bytes (2134)]});
+pass;
(grow-file-size) close "testfile"
(grow-file-size) end
EOF
-my ($string);
-check_archive ({"testfile" => [random_bytes (2134)]});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+my ($fs);
+$fs->{"file$_"} = [random_bytes (512)] foreach 0...49;
+check_archive ($fs);
+pass;
(grow-root-lg) creating and checking "file49"
(grow-root-lg) end
EOF
-my ($fs);
-$fs->{"file$_"} = [random_bytes (512)] foreach 0...49;
-check_archive ($fs);
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+my ($fs);
+$fs->{"file$_"} = [random_bytes (512)] foreach 0...19;
+check_archive ($fs);
+pass;
(grow-root-sm) creating and checking "file19"
(grow-root-sm) end
EOF
-my ($fs);
-$fs->{"file$_"} = [random_bytes (512)] foreach 0...19;
-check_archive ($fs);
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+check_archive ({"testme" => [random_bytes (72943)]});
+pass;
(grow-seq-lg) close "testme"
(grow-seq-lg) end
EOF
-check_archive ({"testme" => [random_bytes (72943)]});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+check_archive ({"testme" => [random_bytes (5678)]});
+pass;
(grow-seq-sm) close "testme"
(grow-seq-sm) end
EOF
-check_archive ({"testme" => [random_bytes (5678)]});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_archive ({"testfile" => ["\0" x 76543]});
+pass;
(grow-sparse) close "testfile"
(grow-sparse) end
EOF
-check_archive ({"testfile" => ["\0" x 76543]});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+check_archive ({"foobar" => [random_bytes (2134)]});
+pass;
(grow-tell) close "foobar"
(grow-tell) end
EOF
-check_archive ({"foobar" => [random_bytes (2134)]});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+my ($a) = random_bytes (8143);
+my ($b) = random_bytes (8143);
+check_archive ({"a" => [$a], "b" => [$b]});
+pass;
(grow-two-files) close "b"
(grow-two-files) end
EOF
-my ($a) = random_bytes (8143);
-my ($b) = random_bytes (8143);
-check_archive ({"a" => [$a], "b" => [$b]});
pass;
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+use tests::random;
+check_archive ({"child-syn-rw" => "tests/filesys/extended/child-syn-rw",
+ "logfile" => [random_bytes (8 * 512)]});
+pass;
(syn-rw) wait for child 4 of 4 returned 3 (expected 3)
(syn-rw) end
EOF
-check_archive ({"child-syn-rw" => "tests/filesys/extended/child-syn-rw",
- "logfile" => [random_bytes (8 * 512)]});
pass;
die if @ARGV != 2;
our ($test, $src_dir) = @ARGV;
+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';
+}
+
my ($msg_file) = tempfile ();
select ($msg_file);
\f
# 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);
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) {
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
}