From: Ben Pfaff Date: Sat, 20 Nov 2004 02:31:09 +0000 (+0000) Subject: More VM tests. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b89f7b007a11fe99163f7328bb3bcd9df9ec08b0;p=pintos-anon More VM tests. --- diff --git a/grading/vm/Make.progs b/grading/vm/Make.progs index 7c18d95..d191fa1 100644 --- a/grading/vm/Make.progs +++ b/grading/vm/Make.progs @@ -21,7 +21,7 @@ mmap_write_SRC = mmap-write.c mmap_exit_SRC = mmap-exit.c mmap_shuffle_SRC = mmap-shuffle.c arc4.c cksum.c -PROGS = $(TESTS) child-linear child-sort +PROGS = $(TESTS) child-linear child-sort child-mm-wrt child_linear_SRC = child-linear.c arc4.c child_sort_SRC = child-sort.c - +child_mm_wrt_SRC = child-mm-wrt.c diff --git a/grading/vm/Makefile b/grading/vm/Makefile index 47f010e..7b3e7f3 100644 --- a/grading/vm/Makefile +++ b/grading/vm/Makefile @@ -6,8 +6,11 @@ DISKS = $(patsubst %,%.dsk,$(TESTS)) disks: $(DISKS) -mmap-close.dsk mmap-exit.dsk mmap-read.dsk mmap-unmap.dsk: sample.txt +mmap-close.dsk mmap-read.dsk mmap-unmap.dsk mmap-twice.dsk: sample.txt +page-parallel.dsk: child-linear +page-merge-seq.dsk page-merge-par.dsk: child-sort mmap-overlap.dsk: zeros +mmap-exit.dsk: child-mm-wrt zeros: dd if=/dev/zero of=$@ bs=1024 count=6 diff --git a/grading/vm/child-mm-wrt.c b/grading/vm/child-mm-wrt.c index 9dbbee8..28a52c6 100644 --- a/grading/vm/child-mm-wrt.c +++ b/grading/vm/child-mm-wrt.c @@ -1,3 +1,12 @@ +#include +#include +#ifdef PINTOS +#include +#else +#include "posix-compat.h" +#endif +#include "sample.inc" + #define ACTUAL ((void *) 0x10000000) int @@ -5,28 +14,31 @@ main (void) { int fd; - printf ("(mmap-write) begin\n"); + printf ("(child-mm-wrt) begin\n"); /* Write file via mmap. */ if (!create ("sample.txt", strlen (sample))) { - printf ("(mmap-write) create() failed\n"); + printf ("(child-mm-wrt) create() failed\n"); return 1; } fd = open ("sample.txt"); if (fd < 0) { - printf ("(mmap-write) open() failed\n"); + printf ("(child-mm-wrt) open() failed\n"); return 1; } if (!mmap (fd, ACTUAL, strlen (sample))) { - printf ("(mmap-write) mmap() failed\n"); + printf ("(child-mm-wrt) mmap() failed\n"); return 1; } memcpy (ACTUAL, sample, strlen (sample)); + + printf ("(child-mm-wrt) end\n"); + return 234; } diff --git a/grading/vm/mmap-close.exp b/grading/vm/mmap-close.exp new file mode 100644 index 0000000..b59b149 --- /dev/null +++ b/grading/vm/mmap-close.exp @@ -0,0 +1,2 @@ +(mmap-close) begin +(mmap-close) end diff --git a/grading/vm/mmap-exit.c b/grading/vm/mmap-exit.c index 87c2565..f49d78e 100644 --- a/grading/vm/mmap-exit.c +++ b/grading/vm/mmap-exit.c @@ -44,7 +44,7 @@ main (void) } read (fd, buf, strlen (sample)); - if (memcmp (ACTUAL, sample, strlen (sample))) + if (memcmp (buf, sample, strlen (sample))) { printf ("(mmap-exit) read of mmap-written file reported bad data\n"); return 1; diff --git a/grading/vm/mmap-exit.exp b/grading/vm/mmap-exit.exp new file mode 100644 index 0000000..f0ae820 --- /dev/null +++ b/grading/vm/mmap-exit.exp @@ -0,0 +1,6 @@ +(mmap-exit) begin +(mmap-exit) run child +(child-mm-wrt) begin +(child-mm-wrt) end +(mmap-exit) child finished +(mmap-exit) end diff --git a/grading/vm/mmap-overlap.c b/grading/vm/mmap-overlap.c index c4a06e6..6153793 100644 --- a/grading/vm/mmap-overlap.c +++ b/grading/vm/mmap-overlap.c @@ -14,6 +14,12 @@ main (void) size_t i; int fd[2]; +#ifndef PINTOS + printf ("Sorry, this test won't work on POSIX,\n" + "because POSIX will accept overlapping mmaps.\n"); + abort (); +#endif + printf ("(mmap-overlap) begin\n"); for (i = 0; i < 2; i++) diff --git a/grading/vm/mmap-overlap.exp b/grading/vm/mmap-overlap.exp new file mode 100644 index 0000000..6b0341a --- /dev/null +++ b/grading/vm/mmap-overlap.exp @@ -0,0 +1 @@ +(mmap-overlap) begin diff --git a/grading/vm/mmap-read.exp b/grading/vm/mmap-read.exp new file mode 100644 index 0000000..e3ae90f --- /dev/null +++ b/grading/vm/mmap-read.exp @@ -0,0 +1,2 @@ +(mmap-read) begin +(mmap-read) end diff --git a/grading/vm/mmap-shuffle.exp b/grading/vm/mmap-shuffle.exp new file mode 100644 index 0000000..ef76d85 --- /dev/null +++ b/grading/vm/mmap-shuffle.exp @@ -0,0 +1,13 @@ +(mmap-shuffle) begin +(mmap-shuffle) init: cksum=1573974830 +(mmap-shuffle) shuffle 0: cksum=1944930050 +(mmap-shuffle) shuffle 1: cksum=3381674432 +(mmap-shuffle) shuffle 2: cksum=3536554503 +(mmap-shuffle) shuffle 3: cksum=373089786 +(mmap-shuffle) shuffle 4: cksum=3509490433 +(mmap-shuffle) shuffle 5: cksum=4003286447 +(mmap-shuffle) shuffle 6: cksum=2956275536 +(mmap-shuffle) shuffle 7: cksum=2417689162 +(mmap-shuffle) shuffle 8: cksum=2870274961 +(mmap-shuffle) shuffle 9: cksum=3894560396 +(mmap-shuffle) end diff --git a/grading/vm/mmap-twice.c b/grading/vm/mmap-twice.c index b3b06d9..f913d1d 100644 --- a/grading/vm/mmap-twice.c +++ b/grading/vm/mmap-twice.c @@ -18,7 +18,7 @@ main (void) for (i = 0; i < 2; i++) { - fd[i] = open ("sample"); + fd[i] = open ("sample.txt"); if (fd[i] < 0) { printf ("(mmap-twice) open() %zu failed\n", i); diff --git a/grading/vm/mmap-twice.exp b/grading/vm/mmap-twice.exp new file mode 100644 index 0000000..302eaea --- /dev/null +++ b/grading/vm/mmap-twice.exp @@ -0,0 +1,2 @@ +(mmap-twice) begin +(mmap-twice) end diff --git a/grading/vm/mmap-unmap.exp b/grading/vm/mmap-unmap.exp new file mode 100644 index 0000000..e69de29 diff --git a/grading/vm/mmap-write.exp b/grading/vm/mmap-write.exp new file mode 100644 index 0000000..b9fa76f --- /dev/null +++ b/grading/vm/mmap-write.exp @@ -0,0 +1,2 @@ +(mmap-write) begin +(mmap-write) end diff --git a/grading/vm/page-merge-par.exp b/grading/vm/page-merge-par.exp new file mode 100644 index 0000000..6a5ba2f --- /dev/null +++ b/grading/vm/page-merge-par.exp @@ -0,0 +1,14 @@ +(page-merge-par) begin +page-merge-par) init +(page-merge-par) sort chunk 0 +(page-merge-par) sort chunk 1 +(page-merge-par) sort chunk 2 +(page-merge-par) sort chunk 3 +(page-merge-par) sort chunk 4 +(page-merge-par) sort chunk 5 +(page-merge-par) sort chunk 6 +(page-merge-par) sort chunk 7 +(page-merge-par) merge +(page-merge-par) verify +(page-merge-par) success, buf_idx=516096 +(page-merge-par) end diff --git a/grading/vm/page-merge-seq.c b/grading/vm/page-merge-seq.c index b451306..306910d 100644 --- a/grading/vm/page-merge-seq.c +++ b/grading/vm/page-merge-seq.c @@ -55,7 +55,7 @@ sort (void) close (fd); /* Sort with subprocess. */ - pid_t child = exec ("child-sort"); + pid_t child = exec ("child-sort buffer"); if (child == -1) { printf ("(page-merge-seq) exec() failed\n"); diff --git a/grading/vm/page-merge-seq.exp b/grading/vm/page-merge-seq.exp new file mode 100644 index 0000000..db78189 --- /dev/null +++ b/grading/vm/page-merge-seq.exp @@ -0,0 +1,22 @@ +(page-merge-seq) begin +page-merge-seq) init +(page-merge-seq) sort chunk 0 +(page-merge-seq) sort chunk 1 +(page-merge-seq) sort chunk 2 +(page-merge-seq) sort chunk 3 +(page-merge-seq) sort chunk 4 +(page-merge-seq) sort chunk 5 +(page-merge-seq) sort chunk 6 +(page-merge-seq) sort chunk 7 +(page-merge-seq) sort chunk 8 +(page-merge-seq) sort chunk 9 +(page-merge-seq) sort chunk 10 +(page-merge-seq) sort chunk 11 +(page-merge-seq) sort chunk 12 +(page-merge-seq) sort chunk 13 +(page-merge-seq) sort chunk 14 +(page-merge-seq) sort chunk 15 +(page-merge-seq) merge +(page-merge-seq) verify +(page-merge-seq) success, buf_idx=1032192 +(page-merge-seq) end diff --git a/grading/vm/page-shuffle.exp b/grading/vm/page-shuffle.exp index 5870dab..48b99ef 100644 --- a/grading/vm/page-shuffle.exp +++ b/grading/vm/page-shuffle.exp @@ -1,13 +1,13 @@ -(page-linear) begin -(page-linear) init: cksum=3115322833 -(page-linear) shuffle 0: cksum=1691062564 -(page-linear) shuffle 1: cksum=1973575879 -(page-linear) shuffle 2: cksum=1647619479 -(page-linear) shuffle 3: cksum=96566261 -(page-linear) shuffle 4: cksum=3885786467 -(page-linear) shuffle 5: cksum=3022003332 -(page-linear) shuffle 6: cksum=3614934266 -(page-linear) shuffle 7: cksum=2704001777 -(page-linear) shuffle 8: cksum=735775156 -(page-linear) shuffle 9: cksum=1864109763 -(page-linear) end +(page-shuffle) begin +(page-shuffle) init: cksum=3115322833 +(page-shuffle) shuffle 0: cksum=63424829 +(page-shuffle) shuffle 1: cksum=3779635387 +(page-shuffle) shuffle 2: cksum=384449947 +(page-shuffle) shuffle 3: cksum=1883585126 +(page-shuffle) shuffle 4: cksum=2588854009 +(page-shuffle) shuffle 5: cksum=2250425557 +(page-shuffle) shuffle 6: cksum=866944104 +(page-shuffle) shuffle 7: cksum=3710004019 +(page-shuffle) shuffle 8: cksum=3936244654 +(page-shuffle) shuffle 9: cksum=2799827580 +(page-shuffle) end diff --git a/grading/vm/panic.diff b/grading/vm/panic.diff new file mode 100644 index 0000000..6134d47 --- /dev/null +++ b/grading/vm/panic.diff @@ -0,0 +1,20 @@ +diff -up /home/blp/cs140/pintos/src/lib/debug.c.\~1.8.\~ /home/blp/cs140/pintos/src/lib/debug.c +--- /home/blp/cs140/pintos/src/lib/debug.c.~1.8.~ 2004-09-12 13:14:11.000000000 -0700 ++++ /home/blp/cs140/pintos/src/lib/debug.c 2004-10-17 00:02:32.000000000 -0700 +@@ -5,6 +5,7 @@ + #include + #include + #ifdef KERNEL ++#include "threads/init.h" + #include "threads/interrupt.h" + #include "devices/serial.h" + #else +@@ -83,7 +84,7 @@ debug_panic (const char *file, int line, + + #ifdef KERNEL + serial_flush (); +- for (;;); ++ power_off (); + #else + exit (1); + #endif diff --git a/grading/vm/pt-write-code.c b/grading/vm/pt-write-code.c index 6954ddf..1b9b4a8 100644 --- a/grading/vm/pt-write-code.c +++ b/grading/vm/pt-write-code.c @@ -5,6 +5,7 @@ main (void) { printf ("(pt-write-code) begin\n"); *(int *) main = 0; + printf ("(pt-write code) fail: writing the code segment succeeded\n"); printf ("(pt-write-code) end\n"); return 0; } diff --git a/grading/vm/pt-write-code.exp b/grading/vm/pt-write-code.exp index f048fc6..e69de29 100644 --- a/grading/vm/pt-write-code.exp +++ b/grading/vm/pt-write-code.exp @@ -1 +0,0 @@ -(pt-write-code) begin diff --git a/grading/vm/random.diff b/grading/vm/random.diff new file mode 100644 index 0000000..bbc1541 --- /dev/null +++ b/grading/vm/random.diff @@ -0,0 +1,37 @@ +--- bitmap.c.~1.5.~ 2004-10-06 14:29:56.000000000 -0700 ++++ bitmap.c 2004-11-03 14:35:22.000000000 -0800 +@@ -1,6 +1,7 @@ + #include "bitmap.h" + #include + #include ++#include + #include + #include + #include "threads/malloc.h" +@@ -212,14 +213,25 @@ size_t + bitmap_scan (const struct bitmap *b, size_t start, size_t cnt, bool value) + { + size_t idx, last; ++ size_t n = 0, m; + + ASSERT (b != NULL); + ASSERT (start <= b->bit_cnt); + + for (idx = start, last = b->bit_cnt - cnt; idx <= last; idx++) + if (!contains (b, idx, idx + cnt, !value)) ++ n++; ++ if (n == 0) ++ return BITMAP_ERROR; ++ ++ random_init (0); ++ m = random_ulong () % n; ++ ++ for (idx = start, last = b->bit_cnt - cnt; idx <= last; idx++) ++ if (!contains (b, idx, idx + cnt, !value) && m-- == 0) + return idx; +- return BITMAP_ERROR; ++ ++ NOT_REACHED (); + } + + /* Finds the first group of CNT consecutive bits in B at or after