summaryrefslogtreecommitdiffstats
path: root/src/tests/vm/child-mm-wrt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/vm/child-mm-wrt.c')
-rw-r--r--src/tests/vm/child-mm-wrt.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tests/vm/child-mm-wrt.c b/src/tests/vm/child-mm-wrt.c
new file mode 100644
index 0000000..8419788
--- /dev/null
+++ b/src/tests/vm/child-mm-wrt.c
@@ -0,0 +1,24 @@
+/* Child process of mmap-exit.
+ Mmaps a file and writes to it via the mmap'ing, then exits
+ without calling munmap. The data in the mapped region must be
+ written out at program termination. */
+
+#include <string.h>
+#include <syscall.h>
+#include "tests/vm/sample.inc"
+#include "tests/lib.h"
+#include "tests/main.h"
+
+#define ACTUAL ((void *) 0x10000000)
+
+void
+test_main (void)
+{
+ int handle;
+
+ CHECK (create ("sample.txt", sizeof sample), "create \"sample.txt\"");
+ CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
+ CHECK (mmap (handle, ACTUAL) != MAP_FAILED, "mmap \"sample.txt\"");
+ memcpy (ACTUAL, sample, sizeof sample);
+}
+