X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=grading%2Ffilesys%2Fsyn-read.c;h=7d2ff3da2ecdbd52cd5adfbbb28f1357f8f9f79c;hb=2969f4df6a95b37e05ad6aa562ae82206b646eb0;hp=d050db7dc4e798b2ec7c6910d9a8c9f16fcd12c7;hpb=0f5c19ccf179b35b39ae46dffec60592baeeec00;p=pintos-anon diff --git a/grading/filesys/syn-read.c b/grading/filesys/syn-read.c index d050db7..7d2ff3d 100644 --- a/grading/filesys/syn-read.c +++ b/grading/filesys/syn-read.c @@ -2,40 +2,27 @@ #include #include #include "fslib.h" +#include "syn-read.h" const char test_name[] = "syn-read"; -static char buf[1024]; +static char buf[BUF_SIZE]; #define CHILD_CNT 10 void test_main (void) { - const char *filename = "data"; pid_t children[CHILD_CNT]; int fd; - int i; - check (create (filename, sizeof buf), "create \"%s\"", filename); - check ((fd = open (filename)) > 1, "open \"%s\"", filename); + CHECK (create (filename, sizeof buf), "create \"%s\"", filename); + CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename); random_bytes (buf, sizeof buf); - check (write (fd, buf, sizeof buf) > 0, "write \"%s\"", filename); + CHECK (write (fd, buf, sizeof buf) > 0, "write \"%s\"", filename); msg ("close \"%s\"", filename); close (fd); - for (i = 0; i < CHILD_CNT; i++) - { - char cmd_line[128]; - snprintf (cmd_line, sizeof cmd_line, - "child-syn-read %d %zu", i, sizeof buf); - check ((children[i] = exec (cmd_line)) != PID_ERROR, - "exec \"%s\"", cmd_line); - } - - 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); - } + exec_children ("child-syn-read", children, CHILD_CNT); + join_children (children, CHILD_CNT); }