summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/filesys/base/syn-read.c
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
committermanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
commitb5f0874cd96ee2a62aabc645b9626c2749cb6a01 (patch)
tree1262e4bbe0634de6650be130c36e0538240f4cbf /pintos-progos/tests/filesys/base/syn-read.c
downloadprogos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.gz
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.bz2
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.zip
initial pintos checkin
Diffstat (limited to 'pintos-progos/tests/filesys/base/syn-read.c')
-rw-r--r--pintos-progos/tests/filesys/base/syn-read.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/pintos-progos/tests/filesys/base/syn-read.c b/pintos-progos/tests/filesys/base/syn-read.c
new file mode 100644
index 0000000..7c36a42
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-read.c
@@ -0,0 +1,31 @@
1/* Spawns 10 child processes, all of which read from the same
2 file and make sure that the contents are what they should
3 be. */
4
5#include <random.h>
6#include <stdio.h>
7#include <syscall.h>
8#include "tests/lib.h"
9#include "tests/main.h"
10#include "tests/filesys/base/syn-read.h"
11
12static char buf[BUF_SIZE];
13
14#define CHILD_CNT 10
15
16void
17test_main (void)
18{
19 pid_t children[CHILD_CNT];
20 int fd;
21
22 CHECK (create (file_name, sizeof buf), "create \"%s\"", file_name);
23 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
24 random_bytes (buf, sizeof buf);
25 CHECK (write (fd, buf, sizeof buf) > 0, "write \"%s\"", file_name);
26 msg ("close \"%s\"", file_name);
27 close (fd);
28
29 exec_children ("child-syn-read", children, CHILD_CNT);
30 wait_children (children, CHILD_CNT);
31}