00001
00002
00003
00004 #include <string.h>
00005 #include <syscall.h>
00006 #include "tests/vm/sample.inc"
00007 #include "tests/lib.h"
00008 #include "tests/main.h"
00009
00010 void
00011 test_main (void)
00012 {
00013 char *actual = (char *) 0x54321000;
00014 int handle;
00015 pid_t child;
00016
00017
00018 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
00019 CHECK (mmap (handle, actual) != MAP_FAILED, "mmap \"sample.txt\"");
00020 if (memcmp (actual, sample, strlen (sample)))
00021 fail ("read of mmap'd file reported bad data");
00022
00023
00024 CHECK ((child = exec ("child-inherit")) != -1, "exec \"child-inherit\"");
00025 quiet = true;
00026 CHECK (wait (child) == -1, "wait for child (should return -1)");
00027 quiet = false;
00028
00029
00030 CHECK (!memcmp (actual, sample, strlen (sample)),
00031 "checking that mmap'd file still has same data");
00032 }