diff options
Diffstat (limited to 'tests/vm/mmap-shuffle.c')
| -rw-r--r-- | tests/vm/mmap-shuffle.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/vm/mmap-shuffle.c b/tests/vm/mmap-shuffle.c new file mode 100644 index 0000000..29921ad --- /dev/null +++ b/tests/vm/mmap-shuffle.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* Creates a 128 kB file and repeatedly shuffles data in it | ||
| 2 | through a memory mapping. */ | ||
| 3 | |||
| 4 | #include <stdio.h> | ||
| 5 | #include <string.h> | ||
| 6 | #include <syscall.h> | ||
| 7 | #include "tests/arc4.h" | ||
| 8 | #include "tests/cksum.h" | ||
| 9 | #include "tests/lib.h" | ||
| 10 | #include "tests/main.h" | ||
| 11 | |||
| 12 | #define SIZE (128 * 1024) | ||
| 13 | |||
| 14 | static char *buf = (char *) 0x10000000; | ||
| 15 | |||
| 16 | void | ||
| 17 | test_main (void) | ||
| 18 | { | ||
| 19 | size_t i; | ||
| 20 | int handle; | ||
| 21 | |||
| 22 | /* Create file, mmap. */ | ||
| 23 | CHECK (create ("buffer", SIZE), "create \"buffer\""); | ||
| 24 | CHECK ((handle = open ("buffer")) > 1, "open \"buffer\""); | ||
| 25 | CHECK (mmap (handle, buf) != MAP_FAILED, "mmap \"buffer\""); | ||
| 26 | |||
| 27 | /* Initialize. */ | ||
| 28 | for (i = 0; i < SIZE; i++) | ||
| 29 | buf[i] = i * 257; | ||
| 30 | msg ("init: cksum=%lu", cksum (buf, SIZE)); | ||
| 31 | |||
| 32 | /* Shuffle repeatedly. */ | ||
| 33 | for (i = 0; i < 10; i++) | ||
| 34 | { | ||
| 35 | shuffle (buf, SIZE, 1); | ||
| 36 | msg ("shuffle %zu: cksum=%lu", i, cksum (buf, SIZE)); | ||
| 37 | } | ||
| 38 | } | ||
