X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=grading%2Ffilesys%2Ffslib.h;h=ea3862490a3d028c807cfc3fcb15aae8097c6d27;hb=e2c971e67570e30eaae1ee16db2e0efe8c13cd75;hp=a0e6f32e583841e57e2eaf200c70848180e7ce6b;hpb=dd2f9330108fbf488d9de8be9b4a7419d0ec97a4;p=pintos-anon diff --git a/grading/filesys/fslib.h b/grading/filesys/fslib.h index a0e6f32..ea38624 100644 --- a/grading/filesys/fslib.h +++ b/grading/filesys/fslib.h @@ -4,13 +4,36 @@ #include #include #include +#include extern const char test_name[]; extern bool quiet; void msg (const char *, ...) PRINTF_FORMAT (1, 2); void fail (const char *, ...) PRINTF_FORMAT (1, 2) NO_RETURN; -void check (bool, const char *, ...) PRINTF_FORMAT (2, 3); + +/* 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__); \ + if (!(SUCCESS)) \ + fail (__VA_ARGS__); \ + } \ + while (0) void shuffle (void *, size_t cnt, size_t size); @@ -21,6 +44,12 @@ void seq_test (const char *filename, 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 join_children (pid_t pids[], size_t child_cnt); + void test_main (void); #endif /* fslib.h */