2 * transsip - the telephony toolkit
3 * libtap (Write tests in C, by Jake Gelbman)
4 * Copyright 2012 Jake Gelbman <gelbman@gmail.com>
5 * Copyright 2012 Daniel Borkmann <borkmann@iogearbox.net>
6 * Subject to the GPL, version 2.
16 #include <sys/types.h>
21 extern int vok_at_loc(const char *file
, int line
, int test
, const char *fmt
,
23 extern int ok_at_loc(const char *file
, int line
, int test
, const char *fmt
,
25 extern int is_at_loc(const char *file
, int line
, const char *got
,
26 const char *expected
, const char *fmt
, ...);
27 extern int isnt_at_loc(const char *file
, int line
, const char *got
,
28 const char *expected
, const char *fmt
, ...);
29 extern int cmp_ok_at_loc(const char *file
, int line
, int a
, const char *op
,
30 int b
, const char *fmt
, ...);
31 extern int bail_out(int ignore
, const char *fmt
, ...);
32 extern void cplan(int tests
, const char *fmt
, ...);
33 extern int diag(const char *fmt
, ...);
34 extern int note(const char *fmt
, ...);
35 extern int exit_status(void);
36 extern void skippy(int n
, const char *fmt
, ...);
37 extern void ctodo(int ignore
, const char *fmt
, ...);
38 extern void cendtodo(void);
43 #define ok(...) ok_at_loc(__FILE__, __LINE__, __VA_ARGS__, NULL)
44 #define is(...) is_at_loc(__FILE__, __LINE__, __VA_ARGS__, NULL)
45 #define isnt(...) isnt_at_loc(__FILE__, __LINE__, __VA_ARGS__, NULL)
46 #define cmp_ok(...) cmp_ok_at_loc(__FILE__, __LINE__, __VA_ARGS__, NULL)
48 #define plan(...) cplan(__VA_ARGS__, NULL)
49 #define done_testing() return exit_status()
50 #define BAIL_OUT(...) bail_out(0, "" __VA_ARGS__, NULL)
52 #define pass(...) ok(1, "" __VA_ARGS__)
53 #define fail(...) ok(0, "" __VA_ARGS__)
55 #define skip(test, ...) do { if (test) { skippy(__VA_ARGS__, NULL); break; }
56 #define endskip } while (0)
58 #define todo(...) ctodo(0, "" __VA_ARGS__, NULL)
59 #define endtodo cendtodo()
61 #define dies_ok(...) dies_ok_common(1, __VA_ARGS__)
62 #define lives_ok(...) dies_ok_common(0, __VA_ARGS__)
64 #define like(...) like_at_loc(1, __FILE__, __LINE__, __VA_ARGS__, NULL)
65 #define unlike(...) like_at_loc(0, __FILE__, __LINE__, __VA_ARGS__, NULL)
67 extern int like_at_loc(int for_match
, const char *file
, int line
,
68 const char *got
, const char *expected
,
69 const char *fmt
, ...);
70 extern int tap_test_died (int status
);
72 #define dies_ok_common(for_death, code, ...) \
82 panic("fork error!\n"); \
91 if (waitpid(cpid, NULL, 0) < 0) \
92 panic("waitpid error!\n"); \
94 it_died = tap_test_died(0); \
98 ok(for_death ? it_died : \
99 !it_died, "" __VA_ARGS__);\