aboutsummaryrefslogtreecommitdiff
path: root/user/include/test/test.h
blob: 3d2296f20eabde3ee9cb33ceb15f3c8ab289f656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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, ...);