Browse code

check for check

git-svn: trunk@4098

aCaB authored on 2008/08/11 01:19:01
Showing 5 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sun Aug 10 18:07:43 CEST 2008 (acab)
2
+------------------------------------
3
+  * unit_tests: check for check version
4
+
1 5
 Sun Aug 10 17:46:12 CEST 2008 (tk)
2 6
 ----------------------------------
3 7
   * freshclam/manager.c: add machine/OS info to the default user agent string
... ...
@@ -238,6 +238,7 @@ static void data_teardown(void)
238 238
 	free(data2);
239 239
 }
240 240
 
241
+#ifdef CHECK_HAVE_LOOPS
241 242
 /* test reading with different alignments, _i is parameter from tcase_add_loop_test */
242 243
 START_TEST (test_cli_readint16)
243 244
 {
... ...
@@ -307,6 +308,7 @@ static Suite *test_cli_suite(void)
307 307
 
308 308
     return s;
309 309
 }
310
+#endif
310 311
 
311 312
 void errmsg_expected(void)
312 313
 {
... ...
@@ -340,7 +342,9 @@ int main(int argc, char **argv)
340 340
     cl_debug();
341 341
     Suite *s = test_cl_suite();
342 342
     SRunner *sr = srunner_create(s);
343
+#ifdef CHECK_HAVE_LOOPS
343 344
     srunner_add_suite(sr, test_cli_suite());
345
+#endif
344 346
     srunner_add_suite(sr, test_jsnorm_suite());
345 347
     srunner_add_suite(sr, test_str_suite());
346 348
     srunner_add_suite(sr, test_regex_suite());
... ...
@@ -60,6 +60,7 @@ static struct test op_test[] = {
60 60
 	{"---",0}
61 61
 };
62 62
 
63
+#ifdef CHECK_HAVE_LOOPS
63 64
 START_TEST (test_keywords)
64 65
 {
65 66
     const struct keyword *kw = in_word_set(kw_test[_i].str, strlen(kw_test[_i].str));
... ...
@@ -80,6 +81,7 @@ START_TEST (test_operators)
80 80
 	    fail_unless(!op, "non-operator detected as operator");
81 81
 }
82 82
 END_TEST
83
+#endif
83 84
 
84 85
 START_TEST (test_token_string)
85 86
 {
... ...
@@ -401,6 +403,7 @@ static struct {
401 401
 	{jstest_buf12, jstest_expected12}
402 402
 };
403 403
 
404
+#ifdef CHECK_HAVE_LOOPS
404 405
 START_TEST (tokenizer_basic)
405 406
 {
406 407
 	tokenizer_test(js_tests[_i].in, js_tests[_i].expected, 0);
... ...
@@ -412,6 +415,7 @@ START_TEST (tokenizer_split)
412 412
 	tokenizer_test(js_tests[_i].in, js_tests[_i].expected, 1);
413 413
 }
414 414
 END_TEST
415
+#endif
415 416
 
416 417
 START_TEST (js_buffer)
417 418
 {
... ...
@@ -458,9 +462,10 @@ Suite *test_jsnorm_suite(void)
458 458
 
459 459
     tc_jsnorm_gperf = tcase_create("jsnorm gperf");
460 460
     suite_add_tcase (s, tc_jsnorm_gperf);
461
+#ifdef CHECK_HAVE_LOOPS
461 462
     tcase_add_loop_test(tc_jsnorm_gperf, test_keywords, 0, sizeof(kw_test)/sizeof(kw_test[0]));
462 463
     tcase_add_loop_test(tc_jsnorm_gperf, test_operators, 0, sizeof(op_test)/sizeof(op_test[0]));
463
-
464
+#endif
464 465
     tc_jsnorm_token = tcase_create("jsnorm token functions");
465 466
     suite_add_tcase (s, tc_jsnorm_token);
466 467
     tcase_add_test(tc_jsnorm_token, test_token_string);
... ...
@@ -477,8 +482,10 @@ Suite *test_jsnorm_suite(void)
477 477
     tc_jsnorm_tokenizer = tcase_create("jsnorm tokenizer");
478 478
     suite_add_tcase (s, tc_jsnorm_tokenizer);
479 479
     tcase_add_checked_fixture (tc_jsnorm_tokenizer, jstest_setup, jstest_teardown);
480
+#ifdef CHECK_HAVE_LOOPS
480 481
     tcase_add_loop_test(tc_jsnorm_tokenizer, tokenizer_basic, 0, sizeof(js_tests)/sizeof(js_tests[0]));
481 482
     tcase_add_loop_test(tc_jsnorm_tokenizer, tokenizer_split, 0, sizeof(js_tests)/sizeof(js_tests[0]));
483
+#endif
482 484
     tcase_add_test(tc_jsnorm_tokenizer, js_buffer);
483 485
 
484 486
     tc_jsnorm_bugs = tcase_create("jsnorm bugs");
... ...
@@ -117,6 +117,7 @@ static int cb_expect_multi(void *cbdata, const char *suffix, size_t len, const s
117 117
 	return 0;
118 118
 }
119 119
 
120
+#ifdef CHECK_HAVE_LOOPS
120 121
 START_TEST (test_suffix)
121 122
 {
122 123
 	int rc;
... ...
@@ -138,6 +139,7 @@ START_TEST (test_suffix)
138 138
 			"suffix number mismatch, expected: %d, was: %d\n", n, cb_called);
139 139
 }
140 140
 END_TEST
141
+#endif
141 142
 
142 143
 static void setup(void)
143 144
 {
... ...
@@ -217,6 +219,7 @@ static const struct rtest {
217 217
 	{NULL,"http://key.com%00fake.example.com","https://key.com",0},
218 218
 };
219 219
 
220
+#ifdef CHECK_HAVE_LOOPS
220 221
 START_TEST (regex_list_match_test)
221 222
 {
222 223
 	const char *info;
... ...
@@ -260,6 +263,7 @@ START_TEST (regex_list_match_test)
260 260
 	free(realurl);
261 261
 }
262 262
 END_TEST
263
+#endif
263 264
 
264 265
 static struct cl_engine *engine;
265 266
 static int loaded_2 = 0;
... ...
@@ -400,12 +404,13 @@ static void do_phishing_test(const struct rtest *rtest)
400 400
 	}
401 401
 }
402 402
 
403
+#ifdef CHECK_HAVE_LOOPS
403 404
 START_TEST (phishingScan_test)
404 405
 {
405 406
 	do_phishing_test(&rtests[_i]);
406 407
 }
407 408
 END_TEST
408
-
409
+#endif
409 410
 
410 411
 START_TEST(phishing_fake_test)
411 412
 {
... ...
@@ -438,24 +443,30 @@ Suite *test_regex_suite(void)
438 438
 	tcase_add_checked_fixture (tc_api, setup, teardown);
439 439
 	tcase_add_test(tc_api, empty);
440 440
 	tcase_add_test(tc_api, one);
441
+#ifdef CHECK_HAVE_LOOPS
441 442
 	tcase_add_loop_test(tc_api, test_suffix, 0, sizeof(tests)/sizeof(tests[0]));
442
-
443
+#endif
443 444
 	tc_matching = tcase_create("regex_list");
444 445
 	suite_add_tcase(s, tc_matching);
445 446
 	tcase_add_checked_fixture (tc_matching, rsetup, rteardown);
447
+#ifdef CHECK_HAVE_LOOPS
446 448
 	tcase_add_loop_test(tc_matching, regex_list_match_test, 0, sizeof(rtests)/sizeof(rtests[0]));
447
-
449
+#endif
448 450
 	tc_phish = tcase_create("phishingScan");
449 451
 	suite_add_tcase(s, tc_phish);
450 452
 	tcase_add_checked_fixture(tc_phish, psetup, pteardown);
453
+#ifdef CHECK_HAVE_LOOPS
451 454
 	tcase_add_loop_test(tc_phish, phishingScan_test, 0, sizeof(rtests)/sizeof(rtests[0]));
455
+#endif
452 456
 	tcase_add_test(tc_phish, phishing_fake_test);
453 457
 
454 458
 
455 459
 	tc_phish2 = tcase_create("phishingScan with 2 dbs");
456 460
 	suite_add_tcase(s, tc_phish2);
457 461
 	tcase_add_checked_fixture(tc_phish2, psetup2, pteardown);
462
+#ifdef CHECK_HAVE_LOOPS
458 463
 	tcase_add_loop_test(tc_phish2, phishingScan_test, 0, sizeof(rtests)/sizeof(rtests[0]));
464
+#endif
459 465
 	tcase_add_test(tc_phish2, phishing_fake_test);
460 466
 
461 467
 	return s;
... ...
@@ -1,5 +1,9 @@
1 1
 #ifndef CHECKS_H
2 2
 #define CHECKS_H
3
+
4
+#if CHECK_MAJOR_VERSION > 0 || ( CHECK_MINOR_VERSION > 9 || ( CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION > 3))
5
+#define CHECK_HAVE_LOOPS
6
+#endif
3 7
 Suite *test_jsnorm_suite(void);
4 8
 Suite *test_str_suite(void);
5 9
 Suite *test_regex_suite(void);