Move problem 1-2 (join) into project 2 as the "wait" system call.
[pintos-anon] / grading / filesys / fslib.h
index b1d654fda4b857a84451f14e5462472151de8537..0d4f12d28d4a9fa9fbedab9d7f128026f3ad1784 100644 (file)
@@ -4,6 +4,7 @@
 #include <debug.h>
 #include <stdbool.h>
 #include <stddef.h>
+#include <syscall.h>
 
 extern const char test_name[];
 extern bool quiet;
@@ -11,7 +12,21 @@ extern bool quiet;
 void msg (const char *, ...) PRINTF_FORMAT (1, 2);
 void fail (const char *, ...) PRINTF_FORMAT (1, 2) NO_RETURN;
 
-#define check(SUCCESS, ...)                     \
+/* Takes an expression to test for SUCCESS and a message, which
+   may include printf-style arguments.  Logs the message, then
+   tests the expression.  If it is zero, indicating failure,
+   emits the message as a failure.
+
+   Somewhat tricky to use:
+
+     - SUCCESS must not have side effects that affect the
+       message, because that will cause the original message and
+       the failure message to differ.
+
+     - The message must not have side effects of its own, because
+       it will be printed twice on failure, or zero times on
+       success if quiet is set. */
+#define CHECK(SUCCESS, ...)                     \
         do                                      \
           {                                     \
             msg (__VA_ARGS__);                  \
@@ -32,6 +47,9 @@ void check_file (const char *filename, const void *buf, size_t filesize);
 void compare_bytes (const void *read_data, const void *expected_data,
                     size_t size, size_t ofs, const char *filename);
 
+void exec_children (const char *child_name, pid_t pids[], size_t child_cnt);
+void wait_children (pid_t pids[], size_t child_cnt);
+
 void test_main (void);
 
 #endif /* fslib.h */