diff options
| author | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
| commit | 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch) | |
| tree | 868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /tests/vm/mmap-inherit.c | |
| parent | eae0bd57f0a26314a94785061888d193d186944a (diff) | |
| download | progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2 progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip | |
reorganize file structure to match the upstream requirements
Diffstat (limited to 'tests/vm/mmap-inherit.c')
| -rw-r--r-- | tests/vm/mmap-inherit.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/vm/mmap-inherit.c b/tests/vm/mmap-inherit.c new file mode 100644 index 0000000..7fa9607 --- /dev/null +++ b/tests/vm/mmap-inherit.c | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* Maps a file into memory and runs child-inherit to verify that | ||
| 2 | mappings are not inherited. */ | ||
| 3 | |||
| 4 | #include <string.h> | ||
| 5 | #include <syscall.h> | ||
| 6 | #include "tests/vm/sample.inc" | ||
| 7 | #include "tests/lib.h" | ||
| 8 | #include "tests/main.h" | ||
| 9 | |||
| 10 | void | ||
| 11 | test_main (void) | ||
| 12 | { | ||
| 13 | char *actual = (char *) 0x54321000; | ||
| 14 | int handle; | ||
| 15 | pid_t child; | ||
| 16 | |||
| 17 | /* Open file, map, verify data. */ | ||
| 18 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); | ||
| 19 | CHECK (mmap (handle, actual) != MAP_FAILED, "mmap \"sample.txt\""); | ||
| 20 | if (memcmp (actual, sample, strlen (sample))) | ||
| 21 | fail ("read of mmap'd file reported bad data"); | ||
| 22 | |||
| 23 | /* Spawn child and wait. */ | ||
| 24 | CHECK ((child = exec ("child-inherit")) != -1, "exec \"child-inherit\""); | ||
| 25 | quiet = true; | ||
| 26 | CHECK (wait (child) == -1, "wait for child (should return -1)"); | ||
| 27 | quiet = false; | ||
| 28 | |||
| 29 | /* Verify data again. */ | ||
| 30 | CHECK (!memcmp (actual, sample, strlen (sample)), | ||
| 31 | "checking that mmap'd file still has same data"); | ||
| 32 | } | ||
