1 /* Maps a file into memory and runs child-inherit to verify that
2 mappings are not inherited. */
6 #include "tests/vm/sample.inc"
8 #include "tests/main.h"
13 char *actual = (char *) 0x54321000;
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");
23 /* Spawn child and wait. */
24 CHECK ((child = exec ("child-inherit")) != -1, "exec \"child-inherit\"");
26 CHECK (wait (child) == -1, "wait for child (should return -1)");
29 /* Verify data again. */
30 CHECK (!memcmp (actual, sample, strlen (sample)),
31 "checking that mmap'd file still has same data");