1 /* Writes to a file through a mapping, and unmaps the file,
2 then reads the data in the file back using the read system
7 #include "tests/vm/sample.inc"
9 #include "tests/main.h"
11 #define ACTUAL ((void *) 0x10000000)
20 /* Write file via mmap. */
21 CHECK (create ("sample.txt", strlen (sample)), "create \"sample.txt\"");
22 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
23 CHECK ((map = mmap (handle, ACTUAL)) != MAP_FAILED, "mmap \"sample.txt\"");
24 memcpy (ACTUAL, sample, strlen (sample));
27 /* Read back via read(). */
28 read (handle, buf, strlen (sample));
29 CHECK (!memcmp (buf, sample, strlen (sample)),
30 "compare read data against written data");