diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 8e75fae0..25827df3 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c @@ -14,6 +14,8 @@ #include "../toxcore/util.h" +#include "helpers.h" + #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) #define c_sleep(x) Sleep(1*x) #else @@ -489,14 +491,6 @@ START_TEST(test_client_invalid) } END_TEST -#define DEFTESTCASE(NAME) \ - TCase *tc_##NAME = tcase_create(#NAME); \ - tcase_add_test(tc_##NAME, test_##NAME); \ - suite_add_tcase(s, tc_##NAME); - -#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ - DEFTESTCASE(NAME) \ - tcase_set_timeout(tc_##NAME, TIMEOUT); Suite *TCP_suite(void) { Suite *s = suite_create("TCP"); diff --git a/auto_tests/assoc_test.c b/auto_tests/assoc_test.c index 5f496ece..b377cadf 100644 --- a/auto_tests/assoc_test.c +++ b/auto_tests/assoc_test.c @@ -1,4 +1,3 @@ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -14,6 +13,8 @@ #include +#include "helpers.h" + START_TEST(test_basics) { /* TODO: real test */ @@ -132,15 +133,6 @@ START_TEST(test_fillup) } END_TEST -#define DEFTESTCASE(NAME) \ - TCase *tc_##NAME = tcase_create(#NAME); \ - tcase_add_test(tc_##NAME, test_##NAME); \ - suite_add_tcase(s, tc_##NAME); - -#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ - DEFTESTCASE(NAME) \ - tcase_set_timeout(tc_##NAME, TIMEOUT); - Suite *Assoc_suite(void) { Suite *s = suite_create("Assoc"); diff --git a/auto_tests/crypto_test.c b/auto_tests/crypto_test.c index 252f7275..2fb08b8b 100644 --- a/auto_tests/crypto_test.c +++ b/auto_tests/crypto_test.c @@ -10,6 +10,8 @@ #include #include +#include "helpers.h" + void rand_bytes(uint8_t *b, size_t blen) { size_t i; @@ -270,16 +272,6 @@ START_TEST(test_large_data_symmetric) } END_TEST - -#define DEFTESTCASE(NAME) \ - TCase *NAME = tcase_create(#NAME); \ - tcase_add_test(NAME, test_##NAME); \ - suite_add_tcase(s, NAME); - -#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ - DEFTESTCASE(NAME) \ - tcase_set_timeout(NAME, TIMEOUT); - Suite *crypto_suite(void) { Suite *s = suite_create("Crypto"); diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h new file mode 100644 index 00000000..30fb7c8c --- /dev/null +++ b/auto_tests/helpers.h @@ -0,0 +1,15 @@ +#ifndef TOXCORE_TEST_HELPERS_H +#define TOXCORE_TEST_HELPERS_H + +#include + +#define DEFTESTCASE(NAME) \ + TCase *tc_##NAME = tcase_create(#NAME); \ + tcase_add_test(tc_##NAME, test_##NAME); \ + suite_add_tcase(s, tc_##NAME); + +#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ + DEFTESTCASE(NAME) \ + tcase_set_timeout(tc_##NAME, TIMEOUT); + +#endif // TOXCORE_TEST_HELPERS_H \ No newline at end of file diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index 7ab7d674..3024ed1a 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c @@ -21,6 +21,8 @@ #include #include +#include "helpers.h" + #define REALLY_BIG_NUMBER ((1) << (sizeof(uint16_t) * 7)) #define STRINGS_EQUAL(X, Y) (strcmp(X, Y) == 0) @@ -298,11 +300,6 @@ START_TEST(test_messenger_state_saveloadsave) } END_TEST -#define DEFTESTCASE(NAME) \ - TCase *tc_##NAME = tcase_create(#NAME); \ - tcase_add_test(tc_##NAME, test_##NAME); \ - suite_add_tcase(s, tc_##NAME); - Suite *messenger_suite(void) { Suite *s = suite_create("Messenger"); diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c index afd90e7a..9d07fbb4 100644 --- a/auto_tests/network_test.c +++ b/auto_tests/network_test.c @@ -11,6 +11,8 @@ #include "../toxcore/network.h" +#include "helpers.h" + START_TEST(test_addr_resolv_localhost) { #ifdef __CYGWIN__ @@ -141,11 +143,6 @@ START_TEST(test_struct_sizes) } END_TEST -#define DEFTESTCASE(NAME) \ - TCase *tc_##NAME = tcase_create(#NAME); \ - tcase_add_test(tc_##NAME, test_##NAME); \ - suite_add_tcase(s, tc_##NAME); - Suite *network_suite(void) { Suite *s = suite_create("Network"); diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 2394e03d..ed297022 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c @@ -14,6 +14,8 @@ #include "../toxcore/onion_client.h" #include "../toxcore/util.h" +#include "helpers.h" + #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) #define c_sleep(x) Sleep(1*x) #else @@ -335,14 +337,6 @@ START_TEST(test_announce) } END_TEST -#define DEFTESTCASE(NAME) \ - TCase *tc_##NAME = tcase_create(#NAME); \ - tcase_add_test(tc_##NAME, test_##NAME); \ - suite_add_tcase(s, tc_##NAME); - -#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ - DEFTESTCASE(NAME) \ - tcase_set_timeout(tc_##NAME, TIMEOUT); Suite *onion_suite(void) { Suite *s = suite_create("Onion"); diff --git a/auto_tests/skeleton_test.c b/auto_tests/skeleton_test.c index 89ef1b8b..27c9123a 100644 --- a/auto_tests/skeleton_test.c +++ b/auto_tests/skeleton_test.c @@ -9,6 +9,8 @@ #include #include +#include "helpers.h" + /* #include "../" */ @@ -20,12 +22,6 @@ START_TEST(test_creativetestnamegoeshere) } END_TEST - -#define DEFTESTCASE(NAME) \ - TCase *tc_##NAME = tcase_create(#NAME); \ - tcase_add_test(tc_##NAME, test_##NAME); \ - suite_add_tcase(s, tc_##NAME); - Suite *creativesuitenamegoeshere_suite(void) { Suite *s = suite_create("creativesuitedescritptiongoeshere"); diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 43fb7a1c..f765fcd3 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c @@ -12,6 +12,8 @@ #include "../toxcore/tox.h" +#include "helpers.h" + #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) #define c_sleep(x) Sleep(1*x) #else @@ -360,14 +362,6 @@ loop_top: } END_TEST -#define DEFTESTCASE(NAME) \ - TCase *tc_##NAME = tcase_create(#NAME); \ - tcase_add_test(tc_##NAME, test_##NAME); \ - suite_add_tcase(s, tc_##NAME); - -#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ - DEFTESTCASE(NAME) \ - tcase_set_timeout(tc_##NAME, TIMEOUT); Suite *tox_suite(void) { Suite *s = suite_create("Tox"); diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index 57685bfc..c6481366 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c @@ -16,6 +16,8 @@ #include "../toxcore/crypto_core.h" #include "../toxav/toxav.h" +#include "helpers.h" + #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) #define c_sleep(x) Sleep(1*x) #else @@ -214,7 +216,6 @@ case 3: /* Wait for Both to have status ended */\ if (status_control.Alice.status == Ended && status_control.Bob.status == Ended) running = 0; break; } c_sleep(20); } } printf("\n"); START_TEST(test_AV_flows) -// int test_AV_flows() { long long unsigned int cur_time = time(NULL); Tox *bootstrap_node = tox_new(0); @@ -574,10 +575,7 @@ Suite *tox_suite(void) { Suite *s = suite_create("ToxAV"); - TCase *tc_av_flows = tcase_create("AV_flows"); - tcase_add_test(tc_av_flows, test_AV_flows); - tcase_set_timeout(tc_av_flows, 200); - suite_add_tcase(s, tc_av_flows); + DEFTESTCASE_SLOW(AV_flows, 200); return s; }