Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / vm / mmap-close.c
1 #include <string.h>
2 #include <syscall.h>
3 #include "tests/vm/sample.inc"
4 #include "tests/arc4.h"
5 #include "tests/lib.h"
6 #include "tests/main.h"
7
8 #define ACTUAL ((void *) 0x10000000)
9
10 void
11 test_main (void)
12 {
13   int handle;
14   mapid_t map;
15
16   CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
17   CHECK ((map = mmap (handle, ACTUAL)) != MAP_FAILED, "mmap \"sample.txt\"");
18
19   close (handle);
20
21   if (memcmp (ACTUAL, sample, strlen (sample)))
22     fail ("read of mmap'd file reported bad data");
23
24   munmap (map);
25 }