Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / vm / mmap-shuffle.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <syscall.h>
4 #include "tests/arc4.h"
5 #include "tests/cksum.h"
6 #include "tests/lib.h"
7 #include "tests/main.h"
8
9 #define SIZE (128 * 1024)
10
11 static char *buf = (char *) 0x10000000;
12
13 void
14 test_main (void)
15 {
16   size_t i;
17   int handle;
18
19   /* Create file, mmap. */
20   CHECK (create ("buffer", SIZE), "create \"buffer\"");
21   CHECK ((handle = open ("buffer")) > 1, "open \"buffer\"");
22   CHECK (mmap (handle, buf) != MAP_FAILED, "mmap \"buffer\"");
23
24   /* Initialize. */
25   for (i = 0; i < SIZE; i++)
26     buf[i] = i * 257;
27   msg ("init: cksum=%lu", cksum (buf, SIZE));
28     
29   /* Shuffle repeatedly. */
30   for (i = 0; i < 10; i++)
31     {
32       shuffle (buf, SIZE, 1);
33       msg ("shuffle %zu: cksum=%lu", i, cksum (buf, SIZE));
34     }
35 }