Ignore more files.
[pintos-anon] / grading / filesys / syn-read.c
1 #include <random.h>
2 #include <stdio.h>
3 #include <syscall.h>
4 #include "fslib.h"
5
6 const char test_name[] = "syn-read";
7
8 static char buf[1024];
9
10 #define CHILD_CNT 10
11
12 void
13 test_main (void) 
14 {
15   const char *filename = "data";
16   pid_t children[CHILD_CNT];
17   int fd;
18   int i;
19
20   check (create (filename, sizeof buf), "create \"%s\"", filename);
21   check ((fd = open (filename)) > 1, "open \"%s\"", filename);
22   random_bytes (buf, sizeof buf);
23   check (write (fd, buf, sizeof buf) > 0, "write \"%s\"", filename);
24   msg ("close \"%s\"", filename);
25   close (fd);
26
27   for (i = 0; i < CHILD_CNT; i++) 
28     {
29       char cmd_line[128];
30       snprintf (cmd_line, sizeof cmd_line,
31                 "child-syn-read %d %zu", i, sizeof buf);
32       check ((children[i] = exec (cmd_line)) != PID_ERROR,
33              "exec \"%s\"", cmd_line);
34     }
35
36   for (i = 0; i < CHILD_CNT; i++) 
37     {
38       int status = join (children[i]);
39       check (status == i, "join child %d of %d", i + 1, (int) CHILD_CNT);
40     }
41 }