136 #define TSTNAME name, __func__, "() " 138 #define TSTNAME name, __FUNCTION__, "() " 140 #define TSTNAME name, "", "" 153 #error <TSTFLAGS is not defined> 157 #define BEGIN() BEGIN_(TSTFLAGS); { extern int tstdef_dummy 159 #define END() (void) tstdef_dummy; } END_(TSTFLAGS) 163 #define TEST0(suite) TEST_1_(TSTFLAGS, suite) 165 #define TEST_1(suite) TEST_1_(TSTFLAGS, suite) 167 #define TEST_VOID(suite) TEST_VOID_(TSTFLAGS, suite) 169 #define TEST(suite, expected) TEST_(TSTFLAGS, suite, expected) 171 #define TEST_P(suite, expected) TEST_P_(TSTFLAGS, suite, expected) 173 #define TEST64(suite, expected) TEST64_(TSTFLAGS, suite, expected) 175 #define TEST_D(suite, expected) TEST_D_(TSTFLAGS, suite, expected) 177 #define TEST_S(suite, expected) TEST_S_(TSTFLAGS, suite, expected) 179 #define TEST_M(suite, expected, len) TEST_M_(TSTFLAGS, suite, expected, len) 181 #define TEST_SIZE(suite, expected) TEST_SIZE_(TSTFLAGS, suite, expected) 184 #define TEST_LOG(x) \ 186 if (tstflags & tst_log) \ 190 #define TEST_FAILED(flags) \ 191 (((flags) & tst_abort) || getenv("SOFIA_SIP_TEST_ABORT")) \ 192 ? abort() : (void)0; return 1 195 #define TEST_1_(flags, suite) do { \ 196 if (flags & tst_verbatim) { \ 197 printf("%s: %s%stesting %s\n", TSTNAME, #suite); \ 199 if ((suite)) { if (flags & tst_verbatim) \ 200 printf("%s: %s%sok: (%s)\n", TSTNAME, #suite); break ; } \ 201 fprintf(stderr, "%s:%u: %s %s%sFAILED: (%s)\n", \ 202 __FILE__, __LINE__, TSTNAME, #suite); fflush(stderr); \ 203 TEST_FAILED(flags); } \ 207 #define TEST_VOID_(flags, suite) do { \ 208 if (flags & tst_verbatim) { \ 209 printf("%s: %s%stesting %s\n", TSTNAME, #suite); \ 214 #define TEST_(flags, suite, expect) do { \ 215 uintptr_t _value, _expect; \ 216 if (flags & tst_verbatim) { \ 217 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 219 _value = (uintptr_t)(suite); \ 220 _expect = (uintptr_t)(expect); \ 221 if (_value == _expect) { \ 222 if (flags & tst_verbatim) \ 223 printf("%s: %s%sok: %s == %s \n", \ 224 TSTNAME, #suite, #expect); \ 227 fprintf(stderr, "%s:%u: %s %s%sFAILED: " \ 228 "%s != %s or "MOD_ZU" != "MOD_ZU"\n", \ 229 __FILE__, __LINE__, TSTNAME, \ 230 #suite, #expect, (size_t)_value, (size_t)_expect); \ 232 TEST_FAILED(flags); \ 236 #define TEST_P_(flags, suite, expect) do { \ 237 void const * _value, * _expect; \ 238 if (flags & tst_verbatim) { \ 239 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 241 if ((_value = (suite)) == (_expect = (expect))) { \ 242 if (flags & tst_verbatim) \ 243 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); \ 246 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %p != %p\n", \ 247 __FILE__, __LINE__, TSTNAME, \ 248 #suite, #expect, _value, _expect); fflush(stderr); \ 249 TEST_FAILED(flags); \ 253 #define TEST_SIZE_(flags, suite, expect) do { \ 254 size_t _value, _expect; \ 255 if (flags & tst_verbatim) { \ 256 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 258 if ((_value = (size_t)(suite)) == \ 259 (_expect = (size_t)(expect))) \ 260 { if (flags & tst_verbatim) \ 261 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \ 262 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or "MOD_ZU" != "MOD_ZU"\n", \ 263 __FILE__, __LINE__, TSTNAME, \ 264 #suite, #expect, _value, _expect); fflush(stderr); \ 265 TEST_FAILED(flags); \ 270 #define TEST64_(flags, suite, expect) do { \ 271 uint64_t _value, _expect; \ 272 if (flags & tst_verbatim) { \ 273 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 275 if ((_value = (uint64_t)(suite)) == (_expect = (uint64_t)(expect))) \ 276 { if (flags & tst_verbatim) \ 277 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \ 278 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or "LLU" != "LLU"\n", \ 279 __FILE__, __LINE__, TSTNAME, \ 280 #suite, #expect, (unsigned longlong)_value, \ 281 (unsigned longlong)_expect); fflush(stderr); \ 282 TEST_FAILED(flags); \ 286 #define TEST_D_(flags, suite, expect) do { \ 287 double _value, _expect; \ 288 if (flags & tst_verbatim) { \ 289 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 291 if ((_value = (double)(suite)) == (_expect = (double)(expect))) \ 292 { if (flags & tst_verbatim) \ 293 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \ 294 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %g != %g\n", \ 295 __FILE__, __LINE__, TSTNAME, \ 296 #suite, #expect, _value, _expect); fflush(stderr); \ 297 TEST_FAILED(flags); \ 301 #define TEST_S_(flags, suite, expect) do { \ 302 char const * _value, * _expect; \ 303 if (flags & tst_verbatim) { \ 304 printf("%s: %s%stesting %s is %s\n", TSTNAME, #suite, #expect); \ 307 _expect = (expect); \ 308 if (((_value == NULL || _expect == NULL) && _value == _expect) || \ 309 (_value != NULL && _expect != NULL && strcmp(_value, _expect) == 0)) \ 310 { if (flags & tst_verbatim) \ 311 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect);break;}\ 312 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %s%s%s != \"%s\"\n", \ 313 __FILE__, __LINE__, TSTNAME, \ 315 _value ? "\"" : "", _value ? _value : "NULL", _value ? "\"" : "", \ 316 _expect); fflush(stderr); \ 317 TEST_FAILED(flags); \ 321 #define TEST_M_(flags, suite, expect, len) do { \ 322 void const * _value, * _expect; \ 324 if (flags & tst_verbatim) { \ 325 printf("%s: %s%stesting %s is %s\n", TSTNAME, #suite, #expect); \ 328 _expect = (expect); \ 329 _len = (size_t)(len); \ 330 if (((_value == NULL || _expect == NULL) && _value == _expect) || \ 331 memcmp(_value, _expect, _len) == 0) \ 332 { if (flags & tst_verbatim) \ 333 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect);break;}\ 334 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s "\ 335 "or \"%.*s\" != \"%.*s\"\n", \ 336 __FILE__, __LINE__, TSTNAME, \ 337 #suite, #expect, (int)_len, \ 338 (char *)_value, (int)_len, (char *)_expect); \ 340 TEST_FAILED(flags); \ 344 #define BEGIN_(flags) \ 345 if (flags & tst_verbatim) printf("%s: %s%sstarting\n", TSTNAME) 348 #define END_(flags) \ 349 if (flags & tst_verbatim) \ 350 printf("%s: %s%sfinished fully successful\n", TSTNAME); \ If (TSTFLAGS & tst_verbatim) is non-zero, be verbatim.
Definition: tstdef.h:145
Basic integer types for su library.
If (TSTFLAGS & tst_log) is non-zero, log intermediate results.
Definition: tstdef.h:149
If (TSTFLAGS & tst_abort) is non-zero, abort() when failed.
Definition: tstdef.h:147