00001 /* Verifies that memory mappings persist after file close. */ 00002 00003 #include <string.h> 00004 #include <syscall.h> 00005 #include "tests/vm/sample.inc" 00006 #include "tests/arc4.h" 00007 #include "tests/lib.h" 00008 #include "tests/main.h" 00009 00010 #define ACTUAL ((void *) 0x10000000) 00011 00012 void 00013 test_main (void) 00014 { 00015 int handle; 00016 mapid_t map; 00017 00018 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 00019 CHECK ((map = mmap (handle, ACTUAL)) != MAP_FAILED, "mmap \"sample.txt\""); 00020 00021 close (handle); 00022 00023 if (memcmp (ACTUAL, sample, strlen (sample))) 00024 fail ("read of mmap'd file reported bad data"); 00025 00026 munmap (map); 00027 }