New test for growing the stack using a system call.
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 4 Jan 2006 21:15:37 +0000 (21:15 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 4 Jan 2006 21:15:37 +0000 (21:15 +0000)
From Godmar Back.

src/tests/vm/Make.tests
src/tests/vm/Rubric.functionality
src/tests/vm/pt-grow-stk-sc.c [new file with mode: 0644]
src/tests/vm/pt-grow-stk-sc.ck [new file with mode: 0644]

index a539f7552e5863901009474685e0d9fc9736ff3e..4a5820d81ed3d75a2330c2b4778220a838c6c4bb 100644 (file)
@@ -4,11 +4,11 @@ PINTOSFLAGS += --swap-disk=4
 
 tests/vm_TESTS = $(addprefix tests/vm/,pt-grow-stack pt-grow-pusha     \
 pt-grow-bad pt-big-stk-obj pt-bad-addr pt-bad-read pt-write-code       \
-pt-write-code2 page-linear page-parallel page-merge-seq page-merge-par \
-page-shuffle mmap-read mmap-close mmap-unmap mmap-overlap mmap-twice   \
-mmap-write mmap-exit mmap-shuffle mmap-bad-fd mmap-clean mmap-inherit  \
-mmap-misalign mmap-null mmap-over-code mmap-over-data mmap-over-stk    \
-mmap-remove mmap-zero)
+pt-write-code2 pt-grow-stk-sc page-linear page-parallel page-merge-seq \
+page-merge-par page-shuffle mmap-read mmap-close mmap-unmap            \
+mmap-overlap mmap-twice mmap-write mmap-exit mmap-shuffle mmap-bad-fd  \
+mmap-clean mmap-inherit mmap-misalign mmap-null mmap-over-code         \
+mmap-over-data mmap-over-stk mmap-remove mmap-zero)
 
 tests/vm_PROGS = $(tests/vm_TESTS) $(addprefix tests/vm/,child-linear  \
 child-sort child-mm-wrt child-inherit)
@@ -24,6 +24,7 @@ tests/vm/pt-bad-addr_SRC = tests/vm/pt-bad-addr.c tests/lib.c tests/main.c
 tests/vm/pt-bad-read_SRC = tests/vm/pt-bad-read.c tests/lib.c tests/main.c
 tests/vm/pt-write-code_SRC = tests/vm/pt-write-code.c tests/lib.c tests/main.c
 tests/vm/pt-write-code2_SRC = tests/vm/pt-write-code-2.c tests/lib.c tests/main.c
+tests/vm/pt-grow-stk-sc_SRC = tests/vm/pt-grow-stk-sc.c tests/lib.c tests/main.c
 tests/vm/page-linear_SRC = tests/vm/page-linear.c tests/arc4.c \
 tests/lib.c tests/main.c
 tests/vm/page-parallel_SRC = tests/vm/page-parallel.c tests/lib.c tests/main.c
index b45f77383131b5d796e84e4ec94f04f1643d1edd..a27ad1a533ed373887df10b726a215148c2a09d2 100644 (file)
@@ -1,6 +1,7 @@
 Functionality of virtual memory subsystem:
 - Test page table.
-6      pt-grow-stack
+4      pt-grow-stack
+2      pt-grow-stk-sc
 6      pt-big-stk-obj
 6      pt-grow-pusha
 
diff --git a/src/tests/vm/pt-grow-stk-sc.c b/src/tests/vm/pt-grow-stk-sc.c
new file mode 100644 (file)
index 0000000..3efbb5f
--- /dev/null
@@ -0,0 +1,32 @@
+/* This test checks that the stack is properly extended even if
+   the first access to a stack location occurs inside a system
+   call.
+
+   From Godmar Back. */
+
+#include <string.h>
+#include <syscall.h>
+#include "tests/vm/sample.inc"
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void)
+{
+  int handle;
+  int slen = strlen (sample);
+  char buf2[65536];
+
+  /* Write file via write(). */
+  CHECK (create ("sample.txt", slen), "create \"sample.txt\"");
+  CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
+  CHECK (write (handle, sample, slen) == slen, "write \"sample.txt\"");
+  close (handle);
+
+  /* Read back via read(). */
+  CHECK ((handle = open ("sample.txt")) > 1, "2nd open \"sample.txt\"");
+  CHECK (read (handle, buf2 + 32768, slen) == slen, "read \"sample.txt\"");
+
+  CHECK (!memcmp (sample, buf2 + 32768, slen), "compare written data against read data");
+  close (handle);
+}
diff --git a/src/tests/vm/pt-grow-stk-sc.ck b/src/tests/vm/pt-grow-stk-sc.ck
new file mode 100644 (file)
index 0000000..005f6f4
--- /dev/null
@@ -0,0 +1,14 @@
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
+(pt-grow-stk-sc) begin
+(pt-grow-stk-sc) create "sample.txt"
+(pt-grow-stk-sc) open "sample.txt"
+(pt-grow-stk-sc) write "sample.txt"
+(pt-grow-stk-sc) 2nd open "sample.txt"
+(pt-grow-stk-sc) read "sample.txt"
+(pt-grow-stk-sc) compare written data against read data
+(pt-grow-stk-sc) end
+EOF