Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / filesys / base / syn-read.c
1 #include <random.h>
2 #include <stdio.h>
3 #include <syscall.h>
4 #include "tests/lib.h"
5 #include "tests/main.h"
6 #include "tests/filesys/base/syn-read.h"
7
8 static char buf[BUF_SIZE];
9
10 #define CHILD_CNT 10
11
12 void
13 test_main (void) 
14 {
15   pid_t children[CHILD_CNT];
16   int fd;
17
18   CHECK (create (filename, sizeof buf), "create \"%s\"", filename);
19   CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename);
20   random_bytes (buf, sizeof buf);
21   CHECK (write (fd, buf, sizeof buf) > 0, "write \"%s\"", filename);
22   msg ("close \"%s\"", filename);
23   close (fd);
24
25   exec_children ("child-syn-read", children, CHILD_CNT);
26   wait_children (children, CHILD_CNT);
27 }