From 1fe736b0384dc7b951866643c886091f66df27f4 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 4 Jan 2006 21:15:37 +0000 Subject: [PATCH] New test for growing the stack using a system call. From Godmar Back. --- src/tests/vm/Make.tests | 11 ++++++----- src/tests/vm/Rubric.functionality | 3 ++- src/tests/vm/pt-grow-stk-sc.c | 32 +++++++++++++++++++++++++++++++ src/tests/vm/pt-grow-stk-sc.ck | 14 ++++++++++++++ 4 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 src/tests/vm/pt-grow-stk-sc.c create mode 100644 src/tests/vm/pt-grow-stk-sc.ck diff --git a/src/tests/vm/Make.tests b/src/tests/vm/Make.tests index a539f75..4a5820d 100644 --- a/src/tests/vm/Make.tests +++ b/src/tests/vm/Make.tests @@ -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 diff --git a/src/tests/vm/Rubric.functionality b/src/tests/vm/Rubric.functionality index b45f773..a27ad1a 100644 --- a/src/tests/vm/Rubric.functionality +++ b/src/tests/vm/Rubric.functionality @@ -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 index 0000000..3efbb5f --- /dev/null +++ b/src/tests/vm/pt-grow-stk-sc.c @@ -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 +#include +#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 index 0000000..005f6f4 --- /dev/null +++ b/src/tests/vm/pt-grow-stk-sc.ck @@ -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 -- 2.30.2