summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/vm/mmap-lazy-seq.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 /pintos-progos/tests/vm/mmap-lazy-seq.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 'pintos-progos/tests/vm/mmap-lazy-seq.c')
-rw-r--r--pintos-progos/tests/vm/mmap-lazy-seq.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/pintos-progos/tests/vm/mmap-lazy-seq.c b/pintos-progos/tests/vm/mmap-lazy-seq.c
deleted file mode 100644
index b8f07bd..0000000
--- a/pintos-progos/tests/vm/mmap-lazy-seq.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/* Create a large file, and mmap it several times, writing to
2 different pages. Then unmaps the file, and reads the data back
3 to verify */
4
5#include <string.h>
6#include <syscall.h>
7#include "tests/vm/sample.inc"
8#include "tests/lib.h"
9#include "tests/main.h"
10
11/* Offset needs to be larger or equal to page size */
12#define OFFSET(i) (8192*(i))
13/* Number of times file is mmapped */
14#define N (8)
15/* Size of file */
16#define FILE_SIZE (1024*1024)
17/* Address for mmap */
18#define ACTUAL(i) ((void *) (0x10000000 + (i)*FILE_SIZE))
19
20
21void
22test_main (void)
23{
24 int i;
25 int handle;
26 mapid_t map[N];
27 char buf[1024];
28 /* create file */
29 CHECK (create ("sample.txt", FILE_SIZE), "create \"sample.txt\"");
30 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
31 /* mmap */
32 for (i = 0; i < N; i++) {
33 CHECK ((map[i] = mmap (handle, ACTUAL(i))) != MAP_FAILED, "mmap \"sample.txt\"");
34 }
35 /* write */
36 for (i = 0; i < N; i++) {
37 memcpy (buf, ACTUAL(i)+OFFSET(i+N), 1024); /* not checked */
38 memcpy (ACTUAL(i)+OFFSET(i), sample, strlen (sample));
39 }
40 /* munmap */
41 for (i = 0; i < N; i++) {
42 munmap (map[i]);
43 }
44 /* Read back via read(). */
45 for (i = 0; i < N; i++) {
46 seek (handle, OFFSET(i));
47 read (handle, buf, strlen (sample));
48 CHECK (!memcmp (buf, sample, strlen (sample)),
49 "compare read data against written data");
50 }
51 close (handle);
52}