|
@@ -15,6 +15,57 @@ ttail_t *ttail;
|
15
|
15
|
#define FNAME_NO_EXIST 0
|
16
|
16
|
#define FNAME_EXIST 1
|
17
|
17
|
|
|
18
|
+/**@brief Start a ttail test
|
|
19
|
+ *@param const char* suite_str test suite string
|
|
20
|
+ *@param const char* tc_str test case string
|
|
21
|
+ */
|
|
22
|
+#define TTAIL_CHECK_START(suite_str, tc_str) \
|
|
23
|
+Suite * ttail_test_suite(void) \
|
|
24
|
+{\
|
|
25
|
+ Suite *s;\
|
|
26
|
+ TCase *tc;\
|
|
27
|
+ s = suite_create(suite_str);\
|
|
28
|
+ tc = tcase_create(tc_str);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+/**@brief Set the setup & teardown fixture
|
|
32
|
+ *@param void (*setup)()
|
|
33
|
+ *@param void (*teardown)()
|
|
34
|
+ */
|
|
35
|
+#define TTAIL_SET_FIXTURE(setup, teardown) \
|
|
36
|
+ tcase_add_checked_fixture(tc, setup, teardown)
|
|
37
|
+/**@brief Add a test function defined using START_TEST(name) { ... } END_TEST
|
|
38
|
+ */
|
|
39
|
+#define TTAIL_ADD_TEST(test) tcase_add_test(tc, test)
|
|
40
|
+
|
|
41
|
+/**@brief End a ttail test */
|
|
42
|
+#define TTAIL_CHECK_END \
|
|
43
|
+ suite_add_tcase(s, tc);\
|
|
44
|
+ return s;\
|
|
45
|
+}\
|
|
46
|
+\
|
|
47
|
+int main(int argc, char **argv) {\
|
|
48
|
+ int n_fail;\
|
|
49
|
+ SRunner *sr;\
|
|
50
|
+ n_fail = chdir(dirname(argv[0])); /* move in ./tests dir */ \
|
|
51
|
+ if(n_fail < 0)\
|
|
52
|
+ {\
|
|
53
|
+ perror("Unable to chdir in tests folder");\
|
|
54
|
+ }\
|
|
55
|
+ sr = srunner_create(ttail_test_suite());\
|
|
56
|
+ srunner_set_fork_status(sr, CK_FORK);\
|
|
57
|
+ srunner_run_all(sr, CK_VERBOSE);\
|
|
58
|
+ n_fail = srunner_ntests_failed(sr);\
|
|
59
|
+ srunner_free(sr);\
|
|
60
|
+ return (n_fail == 0) ? EXIT_SUCCESS : EXIT_FAILURE;\
|
|
61
|
+}
|
|
62
|
+
|
|
63
|
+#define ck_assert_printf(test, format, ...) {\
|
|
64
|
+ char _err_msg[512];\
|
|
65
|
+ snprintf(_err_msg, sizeof(char) * 512,format, __VA_ARGS__);\
|
|
66
|
+ ck_assert_msg(test, _err_msg);\
|
|
67
|
+}
|
|
68
|
+
|
18
|
69
|
char *fname[__Fname_sz];
|
19
|
70
|
/*date formats*/
|
20
|
71
|
char *fmt[] = TTAIL_DEFAULT_FORMATS;
|
|
@@ -107,51 +158,5 @@ void teardown_closest_fileinit(void)
|
107
|
158
|
_ttail_search_file_free(ttail);
|
108
|
159
|
teardown_closest();
|
109
|
160
|
}
|
110
|
|
-
|
111
|
|
-/**@brief Start a ttail test
|
112
|
|
- *@param const char* suite_str test suite string
|
113
|
|
- *@param const char* tc_str test case string
|
114
|
|
- */
|
115
|
|
-#define TTAIL_CHECK_START(suite_str, tc_str) \
|
116
|
|
-Suite * ttail_test_suite(void) \
|
117
|
|
-{\
|
118
|
|
- Suite *s;\
|
119
|
|
- TCase *tc;\
|
120
|
|
- s = suite_create(suite_str);\
|
121
|
|
- tc = tcase_create(tc_str);
|
122
|
|
-
|
123
|
|
-
|
124
|
|
-/**@brief Set the setup & teardown fixture
|
125
|
|
- *@param void (*setup)()
|
126
|
|
- *@param void (*teardown)()
|
127
|
|
- */
|
128
|
|
-#define TTAIL_SET_FIXTURE(setup, teardown) \
|
129
|
|
- tcase_add_checked_fixture(tc, setup, teardown)
|
130
|
|
-/**@brief Add a test function defined using START_TEST(name) { ... } END_TEST
|
131
|
|
- */
|
132
|
|
-#define TTAIL_ADD_TEST(test) tcase_add_test(tc, test)
|
133
|
|
-
|
134
|
|
-/**@brief End a ttail test */
|
135
|
|
-#define TTAIL_CHECK_END \
|
136
|
|
- suite_add_tcase(s, tc);\
|
137
|
|
- return s;\
|
138
|
|
-}\
|
139
|
|
-\
|
140
|
|
-int main(int argc, char **argv) {\
|
141
|
|
- int n_fail;\
|
142
|
|
- SRunner *sr;\
|
143
|
|
- n_fail = chdir(dirname(argv[0])); /* move in ./tests dir */ \
|
144
|
|
- if(n_fail < 0)\
|
145
|
|
- {\
|
146
|
|
- perror("Unable to chdir in tests folder");\
|
147
|
|
- }\
|
148
|
|
- sr = srunner_create(ttail_test_suite());\
|
149
|
|
- srunner_set_fork_status(sr, CK_FORK);\
|
150
|
|
- srunner_run_all(sr, CK_VERBOSE);\
|
151
|
|
- n_fail = srunner_ntests_failed(sr);\
|
152
|
|
- srunner_free(sr);\
|
153
|
|
- return (n_fail == 0) ? EXIT_SUCCESS : EXIT_FAILURE;\
|
154
|
|
-}
|
155
|
|
-
|
156
|
161
|
#endif
|
157
|
162
|
|