Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / filesys / base / child-syn-wrt.c
1 #include <random.h>
2 #include <stdlib.h>
3 #include <syscall.h>
4 #include "tests/lib.h"
5 #include "tests/filesys/base/syn-write.h"
6
7 char buf[BUF_SIZE];
8
9 int
10 main (int argc, char *argv[])
11 {
12   int child_idx;
13   int fd;
14
15   quiet = true;
16   
17   CHECK (argc == 2, "argc must be 2, actually %d", argc);
18   child_idx = atoi (argv[1]);
19
20   random_init (0);
21   random_bytes (buf, sizeof buf);
22
23   CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename);
24   seek (fd, CHUNK_SIZE * child_idx);
25   CHECK (write (fd, buf + CHUNK_SIZE * child_idx, CHUNK_SIZE) > 0,
26          "write \"%s\"", filename);
27   msg ("close \"%s\"", filename);
28   close (fd);
29
30   return child_idx;
31 }