Consistently spell "file name" and "file system" as two words.
[pintos-anon] / src / tests / filesys / extended / syn-rw.c
1 /* Grows a file in chunks while subprocesses read the growing
2    file. */
3
4 #include <random.h>
5 #include <syscall.h>
6 #include "tests/filesys/extended/syn-rw.h"
7 #include "tests/lib.h"
8 #include "tests/main.h"
9
10 char buf[BUF_SIZE];
11
12 #define CHILD_CNT 4
13
14 void
15 test_main (void) 
16 {
17   pid_t children[CHILD_CNT];
18   size_t ofs;
19   int fd;
20
21   CHECK (create (file_name, 0), "create \"%s\"", file_name);
22   CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
23
24   exec_children ("child-syn-rw", children, CHILD_CNT);
25
26   random_bytes (buf, sizeof buf);
27   quiet = true;
28   for (ofs = 0; ofs < BUF_SIZE; ofs += CHUNK_SIZE)
29     CHECK (write (fd, buf + ofs, CHUNK_SIZE) > 0,
30            "write %d bytes at offset %zu in \"%s\"",
31            (int) CHUNK_SIZE, ofs, file_name);
32   quiet = false;
33
34   wait_children (children, CHILD_CNT);
35 }