00001
00002
00003 #include <string.h>
00004 #include <syscall.h>
00005 #include "tests/vm/sample.inc"
00006 #include "tests/lib.h"
00007 #include "tests/main.h"
00008
00009 void
00010 test_main (void)
00011 {
00012 char *actual = (char *) 0x10000000;
00013 int handle;
00014 mapid_t map;
00015 size_t i;
00016
00017 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
00018 CHECK ((map = mmap (handle, actual)) != MAP_FAILED, "mmap \"sample.txt\"");
00019
00020
00021 if (memcmp (actual, sample, strlen (sample)))
00022 fail ("read of mmap'd file reported bad data");
00023
00024
00025 for (i = strlen (sample); i < 4096; i++)
00026 if (actual[i] != 0)
00027 fail ("byte %zu of mmap'd region has value %02hhx (should be 0)",
00028 i, actual[i]);
00029
00030 munmap (map);
00031 close (handle);
00032 }