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 *) 0x10000000;
00014 int handle;
00015 mapid_t map;
00016 size_t i;
00017
00018
00019 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
00020 CHECK ((map = mmap (handle, actual)) != MAP_FAILED, "mmap \"sample.txt\"");
00021
00022
00023 close (handle);
00024 CHECK (remove ("sample.txt"), "remove \"sample.txt\"");
00025 CHECK (open ("sample.txt") == -1, "try to open \"sample.txt\"");
00026
00027
00028
00029
00030 CHECK (create ("another", 4096 * 10), "create \"another\"");
00031
00032
00033 if (memcmp (actual, sample, strlen (sample)))
00034 fail ("read of mmap'd file reported bad data");
00035
00036
00037 for (i = strlen (sample); i < 4096; i++)
00038 if (actual[i] != 0)
00039 fail ("byte %zu of mmap'd region has value %02hhx (should be 0)",
00040 i, actual[i]);
00041
00042 munmap (map);
00043 }