diff options
Diffstat (limited to 'kernel/include/test/usertest.h')
-rw-r--r-- | kernel/include/test/usertest.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/kernel/include/test/usertest.h b/kernel/include/test/usertest.h new file mode 100644 index 0000000..3d2296f --- /dev/null +++ b/kernel/include/test/usertest.h @@ -0,0 +1,51 @@ +#pragma once + +#ifndef __KERNEL__ + +#include "sys/types.h" +#include "unistd.h" + +#else +#include "types.h" +#endif + +#include <stdarg.h> + +#define test_assert(expr, fmt, args...) \ + _test_assert(expr, __FILE__, __LINE__, #expr, fmt, ##args) + +#ifndef __KERNEL__ +#define test_fork_begin() \ + do \ + { \ + pid_t __test_pid = fork(); \ + if (0 == __test_pid) \ + { \ + do + +#define test_fork_end(status) \ + while (0) \ + ; \ + exit(0); \ + } /* if */ \ + waitpid(__test_pid, status, 0); \ + } \ + while (0) \ + ; +#endif + +void test_init(void); + +void test_fini(void); + +const char *test_errstr(int err); + +typedef void (*test_pass_func_t)(int val, const char *file, int line, + const char *name, const char *fmt, + va_list args); + +typedef void (*test_fail_func_t)(const char *file, int line, const char *name, + const char *fmt, va_list args); + +int _test_assert(int val, const char *file, int line, const char *name, + const char *fmt, ...); |