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