diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-03-17 14:48:34 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-03-17 15:04:03 +0000 |
commit | 9706d9a0f015a58937255abd95101045ab865796 (patch) | |
tree | f80d6558912e09b22b4f0c44440e54f92fd40cae /auto_tests/dht_test.c | |
parent | a2496af71aeed3cd7324fb59d9f32c2d52759d56 (diff) |
Disallow stderr logger by default.
Diffstat (limited to 'auto_tests/dht_test.c')
-rw-r--r-- | auto_tests/dht_test.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 2814263f..034147b9 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -322,10 +322,14 @@ static void test_addto_lists_good(DHT *dht, | |||
322 | 322 | ||
323 | static void test_addto_lists(IP ip) | 323 | static void test_addto_lists(IP ip) |
324 | { | 324 | { |
325 | Networking_Core *net = new_networking(nullptr, ip, TOX_PORT_DEFAULT); | 325 | Logger *log = logger_new(); |
326 | uint32_t index = 1; | ||
327 | logger_callback_log(log, (logger_cb *)print_debug_log, nullptr, &index); | ||
328 | |||
329 | Networking_Core *net = new_networking(log, ip, TOX_PORT_DEFAULT); | ||
326 | ck_assert_msg(net != nullptr, "Failed to create Networking_Core"); | 330 | ck_assert_msg(net != nullptr, "Failed to create Networking_Core"); |
327 | 331 | ||
328 | DHT *dht = new_DHT(nullptr, net, true); | 332 | DHT *dht = new_DHT(log, net, true); |
329 | ck_assert_msg(dht != nullptr, "Failed to create DHT"); | 333 | ck_assert_msg(dht != nullptr, "Failed to create DHT"); |
330 | 334 | ||
331 | IP_Port ip_port; | 335 | IP_Port ip_port; |
@@ -453,6 +457,7 @@ static void test_add_to_list(uint8_t cmp_list[][CRYPTO_PUBLIC_KEY_SIZE + 1], | |||
453 | static void test_list_main(void) | 457 | static void test_list_main(void) |
454 | { | 458 | { |
455 | DHT *dhts[NUM_DHT]; | 459 | DHT *dhts[NUM_DHT]; |
460 | uint32_t index[NUM_DHT]; | ||
456 | 461 | ||
457 | uint8_t cmp_list1[NUM_DHT][MAX_FRIEND_CLIENTS][CRYPTO_PUBLIC_KEY_SIZE + 1]; | 462 | uint8_t cmp_list1[NUM_DHT][MAX_FRIEND_CLIENTS][CRYPTO_PUBLIC_KEY_SIZE + 1]; |
458 | memset(cmp_list1, 0, sizeof(cmp_list1)); | 463 | memset(cmp_list1, 0, sizeof(cmp_list1)); |
@@ -463,7 +468,11 @@ static void test_list_main(void) | |||
463 | IP ip; | 468 | IP ip; |
464 | ip_init(&ip, 1); | 469 | ip_init(&ip, 1); |
465 | 470 | ||
466 | dhts[i] = new_DHT(nullptr, new_networking(nullptr, ip, DHT_DEFAULT_PORT + i), true); | 471 | Logger *log = logger_new(); |
472 | index[i] = i + 1; | ||
473 | logger_callback_log(log, (logger_cb *)print_debug_log, nullptr, &index[i]); | ||
474 | |||
475 | dhts[i] = new_DHT(log, new_networking(log, ip, DHT_DEFAULT_PORT + i), true); | ||
467 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); | 476 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); |
468 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); | 477 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); |
469 | } | 478 | } |
@@ -489,15 +498,16 @@ static void test_list_main(void) | |||
489 | } | 498 | } |
490 | } | 499 | } |
491 | 500 | ||
492 | /* | 501 | #if 0 |
493 | print_pk(dhts[0]->self_public_key); | 502 | print_pk(dhts[0]->self_public_key); |
494 | 503 | ||
495 | for (i = 0; i < MAX_FRIEND_CLIENTS; ++i) { | 504 | for (i = 0; i < MAX_FRIEND_CLIENTS; ++i) { |
496 | printf("----Entry %u----\n", i); | 505 | printf("----Entry %u----\n", i); |
497 | 506 | ||
498 | print_pk(cmp_list1[i]); | 507 | print_pk(cmp_list1[i]); |
499 | } | 508 | } |
500 | */ | 509 | |
510 | #endif | ||
501 | unsigned int m_count = 0; | 511 | unsigned int m_count = 0; |
502 | 512 | ||
503 | for (l = 0; l < NUM_DHT; ++l) { | 513 | for (l = 0; l < NUM_DHT; ++l) { |
@@ -592,6 +602,7 @@ START_TEST(test_DHT_test) | |||
592 | { | 602 | { |
593 | uint32_t to_comp = 8394782; | 603 | uint32_t to_comp = 8394782; |
594 | DHT *dhts[NUM_DHT]; | 604 | DHT *dhts[NUM_DHT]; |
605 | uint32_t index[NUM_DHT]; | ||
595 | 606 | ||
596 | unsigned int i, j; | 607 | unsigned int i, j; |
597 | 608 | ||
@@ -599,7 +610,11 @@ START_TEST(test_DHT_test) | |||
599 | IP ip; | 610 | IP ip; |
600 | ip_init(&ip, 1); | 611 | ip_init(&ip, 1); |
601 | 612 | ||
602 | dhts[i] = new_DHT(nullptr, new_networking(nullptr, ip, DHT_DEFAULT_PORT + i), true); | 613 | Logger *log = logger_new(); |
614 | index[i] = i + 1; | ||
615 | logger_callback_log(log, (logger_cb *)print_debug_log, nullptr, &index[i]); | ||
616 | |||
617 | dhts[i] = new_DHT(log, new_networking(log, ip, DHT_DEFAULT_PORT + i), true); | ||
603 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); | 618 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); |
604 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); | 619 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); |
605 | } | 620 | } |