summaryrefslogtreecommitdiffstats
path: root/tests/vm/mmap-twice.c
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
committermanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
commit4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch)
tree868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /tests/vm/mmap-twice.c
parenteae0bd57f0a26314a94785061888d193d186944a (diff)
downloadprogos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz
progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2
progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip
reorganize file structure to match the upstream requirements
Diffstat (limited to 'tests/vm/mmap-twice.c')
-rw-r--r--tests/vm/mmap-twice.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/vm/mmap-twice.c b/tests/vm/mmap-twice.c
new file mode 100644
index 0000000..d277a37
--- /dev/null
+++ b/tests/vm/mmap-twice.c
@@ -0,0 +1,28 @@
1/* Maps the same file into memory twice and verifies that the
2 same data is readable in both. */
3
4#include <string.h>
5#include <syscall.h>
6#include "tests/vm/sample.inc"
7#include "tests/lib.h"
8#include "tests/main.h"
9
10void
11test_main (void)
12{
13 char *actual[2] = {(char *) 0x10000000, (char *) 0x20000000};
14 size_t i;
15 int handle[2];
16
17 for (i = 0; i < 2; i++)
18 {
19 CHECK ((handle[i] = open ("sample.txt")) > 1,
20 "open \"sample.txt\" #%zu", i);
21 CHECK (mmap (handle[i], actual[i]) != MAP_FAILED,
22 "mmap \"sample.txt\" #%zu at %p", i, (void *) actual[i]);
23 }
24
25 for (i = 0; i < 2; i++)
26 CHECK (!memcmp (actual[i], sample, strlen (sample)),
27 "compare mmap'd file %zu against data", i);
28}