diff options
| -rw-r--r-- | src/examples/longrun_nowait.c | 22 | ||||
| -rw-r--r-- | src/examples/pfs.c | 2 | ||||
| -rw-r--r-- | src/tests/Make.tests | 2 | ||||
| -rw-r--r-- | src/tests/filst/Make.tests | 16 | ||||
| -rw-r--r-- | src/tests/filst/sc-bad-write.c | 51 | ||||
| -rw-r--r-- | src/tests/filst/sc-bad-write.ck | 9 | ||||
| -rw-r--r-- | src/userprog/Make.vars | 2 |
7 files changed, 93 insertions, 11 deletions
diff --git a/src/examples/longrun_nowait.c b/src/examples/longrun_nowait.c index 4c78b2e..36f712e 100644 --- a/src/examples/longrun_nowait.c +++ b/src/examples/longrun_nowait.c @@ -4,24 +4,30 @@ Start a lot of processes and let them finish to test if we eventually run out of process slots. - + 'longrun_nowait 10 50' - + Will call generic_parent to start 10 children 50 times (500 processes). One slot will be used by longrun_nowait itself. 50 slots will be used by generic_parent (they must be kept so long as - longrun_nowait still execute, since it may want to wait for any of + longrun_nowait still executes, since it may want to wait for any of them). All other slots needed should also be freed as soon as both generic_parent and it's set of children exits. - + To run the test effectively, if you have a limit on number of - processes, lower that limit to 61 processes and run this test like - + processes, make sure that you have at least 100 slots in your + process table and run this test like + 'longrun_nowait 10 50' - + + You should expect the process list to contain both dummy and + generic_parent. The ratio of dummy to generic_parent processes + should be in favor of generic_parent at most times. Otherwise + something is probably not as it should be. + Note that some pintos tests requires at least 16 simultaneous processes to work, so be sure to increase the limit before running - pintos tests. + pintos tests. */ #include <syscall.h> diff --git a/src/examples/pfs.c b/src/examples/pfs.c index a633e24..3359e5b 100644 --- a/src/examples/pfs.c +++ b/src/examples/pfs.c @@ -1,6 +1,6 @@ /* klaar@ida (cleanup of previous code by various IDA-employees) - pintos -v -k -T 120 --fs-disk=2 --qemu -p ../examples/pfs -a pfs -p ../examples/pfs_writer -a pfs_writer -p ../examples/pfs_reader -a pfs_reader -g messages -- -f -q run pfs + pintos -v -k -T 120 --fs-disk=2 --qemu -p ../examples/pfs -a pfs -p ../examples/pfs_writer -a pfs_writer -p ../examples/pfs_reader -a pfs_reader -g messages -- -F=20000 -f -q run pfs Tests that read and write are properly synchronized. Also stresses the filesystem somewhat. diff --git a/src/tests/Make.tests b/src/tests/Make.tests index bcaa2d1..a9a4459 100644 --- a/src/tests/Make.tests +++ b/src/tests/Make.tests @@ -85,7 +85,7 @@ endif ifeq ($(filter vm, $(KERNEL_SUBDIRS)), vm) TESTCMD += --swap-disk=4 endif -TESTCMD += -- -q +TESTCMD += -- -F=10000 -q TESTCMD += $(KERNELFLAGS) ifeq ($(filter userprog, $(KERNEL_SUBDIRS)), userprog) TESTCMD += -f diff --git a/src/tests/filst/Make.tests b/src/tests/filst/Make.tests new file mode 100644 index 0000000..68bffb1 --- /dev/null +++ b/src/tests/filst/Make.tests @@ -0,0 +1,16 @@ +# -*- makefile -*- + +tests/%.output: FSDISK = 2 +tests/%.output: PUTFILES = $(filter-out os.dsk, $^) + +tests/filst_TESTS = $(addprefix tests/filst/,sc-bad-write) + +tests/filst_PROGS = $(tests/filst_TESTS) # $(addprefix tests/filst/,child-simple) + +tests/filst/sc-bad-write_SRC = tests/filst/sc-bad-write.c tests/main.c + +$(foreach prog,$(tests/filst_PROGS),$(eval $(prog)_SRC += tests/lib.c)) + +tests/filst/read-bad-buf_PUTFILES += tests/filst/sample.txt +tests/filst/low-mem_PUTFILES += tests/filst/child-simple +tests/filst/exec-corrupt_PUTFILES += tests/filst/corrupt-elf diff --git a/src/tests/filst/sc-bad-write.c b/src/tests/filst/sc-bad-write.c new file mode 100644 index 0000000..2280d92 --- /dev/null +++ b/src/tests/filst/sc-bad-write.c @@ -0,0 +1,51 @@ +#include <syscall-nr.h> +#include <stdio.h> +#include <stdint.h> +#include "tests/lib.h" +#include "tests/main.h" + +/** + * From threads/vaddr.h: + */ +#define BITMASK(SHIFT, CNT) (((1ul << (CNT)) - 1) << (SHIFT)) + +#define PGSHIFT 0 /* Index of first offset bit. */ +#define PGBITS 12 /* Number of offset bits. */ +#define PGSIZE (1 << PGBITS) /* Bytes in a page. */ +#define PGMASK BITMASK(PGSHIFT, PGBITS) /* Page offset bits (0:12). */ + +static inline void *pg_round_up (const void *va) { + return (void *) (((uintptr_t) va + PGSIZE - 1) & ~PGMASK); +} + +/** + * A global variable that will give us an address in the BSS segment. + */ +int global = 3; + +void test_main(void) +{ + // Get the addres of the first unmapped page in the system. + unsigned page = (unsigned)pg_round_up(&global); + + // Reserve space for 3 parameters (write requires 4). + page -= sizeof(int) * 4; + + asm volatile ( + "movl %%esp, %%edi;" + "movl %0, %%esp;" // Set stack pointer to right below page boundary. + "movl %1, (%%esp);" // Try to call SYS_WRITE + "movl %2, 4(%%esp);" // Write to STDOUT + "movl %3, 8(%%esp);" // Load buffer. + //"movl $5, 12(%%esp);" // Can not write the last parameter as we would get a pagefault. + "int $0x30;" + "movl %%edi, %%esp;" // Restore esp in case we do not crash (as we should). + : + : "r" (page), + "i" (SYS_WRITE), + "i" (STDOUT_FILENO), + "i" ("TEST\n") + : "%esp", "%eax", "%edi"); + + fail("should have died."); +} diff --git a/src/tests/filst/sc-bad-write.ck b/src/tests/filst/sc-bad-write.ck new file mode 100644 index 0000000..bd393c0 --- /dev/null +++ b/src/tests/filst/sc-bad-write.ck @@ -0,0 +1,9 @@ +# -*- perl -*- +use strict; +use warnings; +use tests::tests; +check_expected ([<<'EOF']); +(sc-bad-write) begin +sc-bad-write: exit(-1) +EOF +pass; diff --git a/src/userprog/Make.vars b/src/userprog/Make.vars index 4335438..f158791 100644 --- a/src/userprog/Make.vars +++ b/src/userprog/Make.vars @@ -2,7 +2,7 @@ os.dsk: DEFINES += -DUSERPROG -DFILESYS KERNEL_SUBDIRS = threads devices lib lib/kernel userprog filesys -TEST_SUBDIRS = tests/klaar tests/userprog tests/filesys/base +TEST_SUBDIRS = tests/klaar tests/filst tests/userprog tests/filesys/base # tests/userprog/no-vm GRADING_FILE = $(SRCDIR)/tests/userprog/Grading SIMULATOR = --qemu |
