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