Get rid of unnecessary barrier. Improve comment.
[pintos-anon] / grading / filesys / syn-write.c
index ee88c8b5442fce15ea8536cc630f6a80cb32a2f5..b21edce11e956a5ac8c8144393872738e3f6e4bd 100644 (file)
@@ -15,26 +15,14 @@ test_main (void)
 {
   pid_t children[CHILD_CNT];
   int fd;
-  int i;
 
-  check (create (filename, sizeof buf1), "create \"%s\"", filename);
+  CHECK (create (filename, sizeof buf1), "create \"%s\"", filename);
 
-  for (i = 0; i < CHILD_CNT; i++) 
-    {
-      char cmd_line[128];
-      snprintf (cmd_line, sizeof cmd_line, "child-syn-wrt %d", i);
-      check ((children[i] = exec (cmd_line)) != PID_ERROR,
-             "exec child %d of %d: \"%s\"", i + 1, (int) CHILD_CNT, cmd_line);
-    }
+  exec_children ("child-syn-wrt", children, CHILD_CNT);
+  wait_children (children, CHILD_CNT);
 
-  for (i = 0; i < CHILD_CNT; i++) 
-    {
-      int status = join (children[i]);
-      check (status == i, "join child %d of %d", i + 1, (int) CHILD_CNT);
-    }
-
-  check ((fd = open (filename)) > 1, "open \"%s\"", filename);
-  check (read (fd, buf1, sizeof buf1) > 0, "read \"%s\"", filename);
+  CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename);
+  CHECK (read (fd, buf1, sizeof buf1) > 0, "read \"%s\"", filename);
   random_bytes (buf2, sizeof buf2);
   compare_bytes (buf1, buf2, sizeof buf1, 0, filename);
 }