X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=grading%2Ffilesys%2Ffslib.c;h=be17f298d73a89587eee0a00c212ca084f89f166;hb=60cba7a21c87442984f87f97597173e2b6357ac0;hp=d5eeda8c1ac220f60d6b631644c315ffe33f5c0e;hpb=5db27be45b12cc35feb6f1de19861d180e5620fe;p=pintos-anon diff --git a/grading/filesys/fslib.c b/grading/filesys/fslib.c index d5eeda8..be17f29 100644 --- a/grading/filesys/fslib.c +++ b/grading/filesys/fslib.c @@ -56,8 +56,8 @@ seq_test (const char *filename, void *buf, size_t size, size_t initial_size, int fd; random_bytes (buf, size); - check (create (filename, initial_size), "create \"%s\"", filename); - check ((fd = open (filename)) > 1, "open \"%s\"", filename); + CHECK (create (filename, initial_size), "create \"%s\"", filename); + CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename); ofs = 0; msg ("writing \"%s\"", filename); @@ -116,7 +116,7 @@ check_file (const char *filename, const void *buf_, size_t size) char block[512]; int fd; - check ((fd = open (filename)) > 1, "open \"%s\" for verification", filename); + CHECK ((fd = open (filename)) > 1, "open \"%s\" for verification", filename); ofs = 0; while (ofs < size) @@ -172,3 +172,31 @@ compare_bytes (const void *read_data_, const void *expected_data_, size_t size, fail ("%zu bytes read starting at offset %zu in \"%s\" differ " "from expected", j - i, ofs, filename); } + +void +exec_children (const char *child_name, pid_t pids[], size_t child_cnt) +{ + size_t i; + + for (i = 0; i < child_cnt; i++) + { + char cmd_line[128]; + snprintf (cmd_line, sizeof cmd_line, "%s %zu", child_name, i); + CHECK ((pids[i] = exec (cmd_line)) != PID_ERROR, + "exec child %zu of %zu: \"%s\"", i + 1, child_cnt, cmd_line); + } +} + +void +join_children (pid_t pids[], size_t child_cnt) +{ + size_t i; + + for (i = 0; i < child_cnt; i++) + { + int status = join (pids[i]); + CHECK (status == (int) i, + "join child %zu of %zu returned %d (expected %zu)", + i + 1, child_cnt, status, i); + } +}