More VM tests.
[pintos-anon] / grading / vm / mmap-overlap.c
1 #include <stdio.h>
2 #include <string.h>
3 #ifdef PINTOS
4 #include <syscall.h>
5 #else
6 #include "posix-compat.h"
7 #endif
8 #include "sample.inc"
9
10 int
11 main (void) 
12 {
13   char *start = (char *) 0x10000000;
14   size_t i;
15   int fd[2];
16
17   printf ("(mmap-overlap) begin\n");
18
19   for (i = 0; i < 2; i++) 
20     {
21       fd[i] = open ("zeros");
22       if (fd[i] < 0) 
23         {
24           printf ("(mmap-overlap) open() failed\n");
25           return 1;
26         }
27       if (!mmap (fd[i], start, 8192))
28         {
29           if (i == 1) 
30             return 0;
31           else
32             {
33               printf ("(mmap-overlap) mmap() failed\n");
34               return 1; 
35             }
36         }
37       start += 4096;
38     }
39
40   printf ("(mmap-overlap) fail: mmap of overlapped blocks succeeded\n");
41
42   /* Done. */
43   printf ("(mmap-overlap) end\n");
44
45   return 0;
46 }