00001 #ifndef TESTS_LIB_H
00002
00003 #define TESTS_LIB_H
00004
00005 #include <debug.h>
00006 #include <stdbool.h>
00007 #include <stddef.h>
00008 #include <syscall.h>
00009
00010 extern const char *test_name;
00011 extern bool quiet;
00012
00013 void msg (const char *, ...) PRINTF_FORMAT (1, 2);
00014 void fail (const char *, ...) PRINTF_FORMAT (1, 2) NO_RETURN;
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #define CHECK(SUCCESS, ...) \
00031 do \
00032 { \
00033 msg (__VA_ARGS__); \
00034 if (!(SUCCESS)) \
00035 fail (__VA_ARGS__); \
00036 } \
00037 while (0)
00038
00039 void shuffle (void *, size_t cnt, size_t size);
00040
00041 void exec_children (const char *child_name, pid_t pids[], size_t child_cnt);
00042 void wait_children (pid_t pids[], size_t child_cnt);
00043
00044 void check_file_handle (int fd, const char *file_name,
00045 const void *buf_, size_t filesize);
00046 void check_file (const char *file_name, const void *buf, size_t filesize);
00047
00048 void compare_bytes (const void *read_data, const void *expected_data,
00049 size_t size, size_t ofs, const char *file_name);
00050
00051 #endif