00001
00002
00003
00004
00005 #include <string.h>
00006 #include <syscall.h>
00007 #include "tests/vm/sample.inc"
00008 #include "tests/lib.h"
00009 #include "tests/main.h"
00010
00011 #define ACTUAL ((void *) 0x10000000)
00012
00013 void
00014 test_main (void)
00015 {
00016 int handle;
00017 mapid_t map;
00018 char buf[1024];
00019
00020
00021 CHECK (create ("sample.txt", strlen (sample)), "create \"sample.txt\"");
00022 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
00023 CHECK ((map = mmap (handle, ACTUAL)) != MAP_FAILED, "mmap \"sample.txt\"");
00024 memcpy (ACTUAL, sample, strlen (sample));
00025 munmap (map);
00026
00027
00028 read (handle, buf, strlen (sample));
00029 CHECK (!memcmp (buf, sample, strlen (sample)),
00030 "compare read data against written data");
00031 close (handle);
00032 }