More VM tests.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 20 Nov 2004 02:31:09 +0000 (02:31 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 20 Nov 2004 02:31:09 +0000 (02:31 +0000)
22 files changed:
grading/vm/Make.progs
grading/vm/Makefile
grading/vm/child-mm-wrt.c
grading/vm/mmap-close.exp [new file with mode: 0644]
grading/vm/mmap-exit.c
grading/vm/mmap-exit.exp [new file with mode: 0644]
grading/vm/mmap-overlap.c
grading/vm/mmap-overlap.exp [new file with mode: 0644]
grading/vm/mmap-read.exp [new file with mode: 0644]
grading/vm/mmap-shuffle.exp [new file with mode: 0644]
grading/vm/mmap-twice.c
grading/vm/mmap-twice.exp [new file with mode: 0644]
grading/vm/mmap-unmap.exp [new file with mode: 0644]
grading/vm/mmap-write.exp [new file with mode: 0644]
grading/vm/page-merge-par.exp [new file with mode: 0644]
grading/vm/page-merge-seq.c
grading/vm/page-merge-seq.exp [new file with mode: 0644]
grading/vm/page-shuffle.exp
grading/vm/panic.diff [new file with mode: 0644]
grading/vm/pt-write-code.c
grading/vm/pt-write-code.exp
grading/vm/random.diff [new file with mode: 0644]

index 7c18d951007e98ac5fedc6efca48baf705c880b3..d191fa19cd01d5d4d06632d35c3f52f5b27a1741 100644 (file)
@@ -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
index 47f010eaeabeb657d9a05d4fd378419512c02934..7b3e7f32f4f60e3101be8bf0c6d214ab458a6287 100644 (file)
@@ -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
index 9dbbee8e00687ea46c9c88d735483e01d795ee4b..28a52c61825a216ca3b11b0f7fa372affc7d8969 100644 (file)
@@ -1,3 +1,12 @@
+#include <stdio.h>
+#include <string.h>
+#ifdef PINTOS
+#include <syscall.h>
+#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 (file)
index 0000000..b59b149
--- /dev/null
@@ -0,0 +1,2 @@
+(mmap-close) begin
+(mmap-close) end
index 87c256503dcb4ef379c6f38b9299da121d98cb01..f49d78eef9f3f604a25893919676963bc183790b 100644 (file)
@@ -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 (file)
index 0000000..f0ae820
--- /dev/null
@@ -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
index c4a06e67c0560cbce15a9187cc84070178472728..6153793911201b7342fe54c1639f14ff6b449d01 100644 (file)
@@ -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 (file)
index 0000000..6b0341a
--- /dev/null
@@ -0,0 +1 @@
+(mmap-overlap) begin
diff --git a/grading/vm/mmap-read.exp b/grading/vm/mmap-read.exp
new file mode 100644 (file)
index 0000000..e3ae90f
--- /dev/null
@@ -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 (file)
index 0000000..ef76d85
--- /dev/null
@@ -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
index b3b06d931d74b0f39075f24621ecd67ab1aead98..f913d1d92d3dd12c1ac9716eee38e2cdadf2a6b4 100644 (file)
@@ -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 (file)
index 0000000..302eaea
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
diff --git a/grading/vm/mmap-write.exp b/grading/vm/mmap-write.exp
new file mode 100644 (file)
index 0000000..b9fa76f
--- /dev/null
@@ -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 (file)
index 0000000..6a5ba2f
--- /dev/null
@@ -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
index b451306d4f64be6631f303ad35d61208b2e6ea8a..306910d964875cea97cb882401bd8c3f9a1516d7 100644 (file)
@@ -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 (file)
index 0000000..db78189
--- /dev/null
@@ -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
index 5870dab9e2417a7a0d942f6b0cddc6149fb75148..48b99ef7d0af4f2e0942f2dad8003dc466404e81 100644 (file)
@@ -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 (file)
index 0000000..6134d47
--- /dev/null
@@ -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 <stdio.h>
+ #include <string.h>
+ #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
index 6954ddf6868a9bdf5c3fc1731cc3d89c26dc4133..1b9b4a8f99f9721941d29711a993be4da7a01c04 100644 (file)
@@ -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;
 }
index f048fc6a3a4fe14eb3cb5f696dace028a0e096a4..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-(pt-write-code) begin
diff --git a/grading/vm/random.diff b/grading/vm/random.diff
new file mode 100644 (file)
index 0000000..bbc1541
--- /dev/null
@@ -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 <debug.h>
+ #include <limits.h>
++#include <random.h>
+ #include <round.h>
+ #include <stdio.h>
+ #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