diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-28 21:30:39 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-30 23:35:50 +0000 |
commit | 92ffad1a72bc8c422426d52ac408bd71242dd047 (patch) | |
tree | f592f353068dd2043525dd2cc04d6124a4ed4bc4 /auto_tests | |
parent | 623e9ac331df7323660e21c8a2226523a5ee713b (diff) |
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
Diffstat (limited to 'auto_tests')
25 files changed, 471 insertions, 333 deletions
diff --git a/auto_tests/BUILD.bazel b/auto_tests/BUILD.bazel index 8e218b51..ea3682b8 100644 --- a/auto_tests/BUILD.bazel +++ b/auto_tests/BUILD.bazel | |||
@@ -1,5 +1,3 @@ | |||
1 | load("//tools:no_undefined.bzl", "cc_library") | ||
2 | |||
3 | cc_library( | 1 | cc_library( |
4 | name = "helpers", | 2 | name = "helpers", |
5 | testonly = True, | 3 | testonly = True, |
@@ -26,4 +24,29 @@ cc_library( | |||
26 | "//c-toxcore/toxencryptsave", | 24 | "//c-toxcore/toxencryptsave", |
27 | "@check", | 25 | "@check", |
28 | ], | 26 | ], |
29 | ) for src in glob(["*_test.c*"])] | 27 | ) for src in glob(["*_test.c"])] |
28 | |||
29 | cc_library( | ||
30 | name = "monolith", | ||
31 | hdrs = glob([ | ||
32 | "*.c", | ||
33 | "*.h", | ||
34 | ]), | ||
35 | ) | ||
36 | |||
37 | cc_test( | ||
38 | name = "monolith_test", | ||
39 | size = "small", | ||
40 | srcs = ["monolith_test.cpp"], | ||
41 | copts = [ | ||
42 | "-Wno-parentheses", | ||
43 | "-Wno-sign-compare", | ||
44 | ], | ||
45 | deps = [ | ||
46 | ":helpers", | ||
47 | ":monolith", | ||
48 | "//c-toxcore/other:monolith", | ||
49 | "//c-toxcore/testing:misc_tools", | ||
50 | "@check", | ||
51 | ], | ||
52 | ) | ||
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 79d83800..26a95942 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #ifndef _XOPEN_SOURCE | ||
1 | #define _XOPEN_SOURCE 600 | 2 | #define _XOPEN_SOURCE 600 |
3 | #endif | ||
2 | 4 | ||
3 | #ifdef HAVE_CONFIG_H | 5 | #ifdef HAVE_CONFIG_H |
4 | #include "config.h" | 6 | #include "config.h" |
@@ -29,6 +31,7 @@ | |||
29 | # undef TOX_AF_INET6 | 31 | # undef TOX_AF_INET6 |
30 | # define TOX_AF_INET6 TOX_AF_INET | 32 | # define TOX_AF_INET6 TOX_AF_INET |
31 | # define get_ip6_loopback get_ip4_loopback | 33 | # define get_ip6_loopback get_ip4_loopback |
34 | # define IP6 IP4 | ||
32 | #endif | 35 | #endif |
33 | 36 | ||
34 | static inline IP get_loopback() | 37 | static inline IP get_loopback() |
@@ -51,8 +54,8 @@ START_TEST(test_basic) | |||
51 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 54 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
52 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 55 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
53 | crypto_new_keypair(self_public_key, self_secret_key); | 56 | crypto_new_keypair(self_public_key, self_secret_key); |
54 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, NULL); | 57 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
55 | ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); | 58 | ck_assert_msg(tcp_s != nullptr, "Failed to create TCP relay server"); |
56 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports"); | 59 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports"); |
57 | 60 | ||
58 | Socket sock = net_socket(TOX_AF_INET6, TOX_SOCK_STREAM, TOX_PROTO_TCP); | 61 | Socket sock = net_socket(TOX_AF_INET6, TOX_SOCK_STREAM, TOX_PROTO_TCP); |
@@ -236,8 +239,8 @@ START_TEST(test_some) | |||
236 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 239 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
237 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 240 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
238 | crypto_new_keypair(self_public_key, self_secret_key); | 241 | crypto_new_keypair(self_public_key, self_secret_key); |
239 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, NULL); | 242 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
240 | ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); | 243 | ck_assert_msg(tcp_s != nullptr, "Failed to create TCP relay server"); |
241 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports"); | 244 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports"); |
242 | 245 | ||
243 | struct sec_TCP_con *con1 = new_TCP_con(tcp_s); | 246 | struct sec_TCP_con *con1 = new_TCP_con(tcp_s); |
@@ -413,8 +416,8 @@ START_TEST(test_client) | |||
413 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 416 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
414 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 417 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
415 | crypto_new_keypair(self_public_key, self_secret_key); | 418 | crypto_new_keypair(self_public_key, self_secret_key); |
416 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, NULL); | 419 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
417 | ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); | 420 | ck_assert_msg(tcp_s != nullptr, "Failed to create TCP relay server"); |
418 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports"); | 421 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports"); |
419 | 422 | ||
420 | uint8_t f_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 423 | uint8_t f_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
@@ -424,23 +427,23 @@ START_TEST(test_client) | |||
424 | 427 | ||
425 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); | 428 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); |
426 | ip_port_tcp_s.ip = get_loopback(); | 429 | ip_port_tcp_s.ip = get_loopback(); |
427 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, 0); | 430 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr); |
428 | c_sleep(50); | 431 | c_sleep(50); |
429 | do_TCP_connection(conn, NULL); | 432 | do_TCP_connection(conn, nullptr); |
430 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_UNCONFIRMED, "Wrong status. Expected: %u, is: %u", | 433 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_UNCONFIRMED, "Wrong status. Expected: %u, is: %u", |
431 | TCP_CLIENT_UNCONFIRMED, tcp_con_status(conn)); | 434 | TCP_CLIENT_UNCONFIRMED, tcp_con_status(conn)); |
432 | c_sleep(50); | 435 | c_sleep(50); |
433 | do_TCP_server(tcp_s); | 436 | do_TCP_server(tcp_s); |
434 | c_sleep(50); | 437 | c_sleep(50); |
435 | do_TCP_connection(conn, NULL); | 438 | do_TCP_connection(conn, nullptr); |
436 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED, | 439 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED, |
437 | tcp_con_status(conn)); | 440 | tcp_con_status(conn)); |
438 | c_sleep(500); | 441 | c_sleep(500); |
439 | do_TCP_connection(conn, NULL); | 442 | do_TCP_connection(conn, nullptr); |
440 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED, | 443 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED, |
441 | tcp_con_status(conn)); | 444 | tcp_con_status(conn)); |
442 | c_sleep(500); | 445 | c_sleep(500); |
443 | do_TCP_connection(conn, NULL); | 446 | do_TCP_connection(conn, nullptr); |
444 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED, | 447 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED, |
445 | tcp_con_status(conn)); | 448 | tcp_con_status(conn)); |
446 | do_TCP_server(tcp_s); | 449 | do_TCP_server(tcp_s); |
@@ -452,20 +455,21 @@ START_TEST(test_client) | |||
452 | uint8_t f2_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 455 | uint8_t f2_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
453 | crypto_new_keypair(f2_public_key, f2_secret_key); | 456 | crypto_new_keypair(f2_public_key, f2_secret_key); |
454 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); | 457 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); |
455 | TCP_Client_Connection *conn2 = new_TCP_connection(ip_port_tcp_s, self_public_key, f2_public_key, f2_secret_key, 0); | 458 | TCP_Client_Connection *conn2 = new_TCP_connection( |
459 | ip_port_tcp_s, self_public_key, f2_public_key, f2_secret_key, nullptr); | ||
456 | routing_response_handler(conn, response_callback, (char *)conn + 2); | 460 | routing_response_handler(conn, response_callback, (char *)conn + 2); |
457 | routing_status_handler(conn, status_callback, (void *)2); | 461 | routing_status_handler(conn, status_callback, (void *)2); |
458 | routing_data_handler(conn, data_callback, (void *)3); | 462 | routing_data_handler(conn, data_callback, (void *)3); |
459 | oob_data_handler(conn, oob_data_callback, (void *)4); | 463 | oob_data_handler(conn, oob_data_callback, (void *)4); |
460 | oob_data_callback_good = response_callback_good = status_callback_good = data_callback_good = 0; | 464 | oob_data_callback_good = response_callback_good = status_callback_good = data_callback_good = 0; |
461 | c_sleep(50); | 465 | c_sleep(50); |
462 | do_TCP_connection(conn, NULL); | 466 | do_TCP_connection(conn, nullptr); |
463 | do_TCP_connection(conn2, NULL); | 467 | do_TCP_connection(conn2, nullptr); |
464 | c_sleep(50); | 468 | c_sleep(50); |
465 | do_TCP_server(tcp_s); | 469 | do_TCP_server(tcp_s); |
466 | c_sleep(50); | 470 | c_sleep(50); |
467 | do_TCP_connection(conn, NULL); | 471 | do_TCP_connection(conn, nullptr); |
468 | do_TCP_connection(conn2, NULL); | 472 | do_TCP_connection(conn2, nullptr); |
469 | c_sleep(50); | 473 | c_sleep(50); |
470 | uint8_t data[5] = {1, 2, 3, 4, 5}; | 474 | uint8_t data[5] = {1, 2, 3, 4, 5}; |
471 | memcpy(oob_pubkey, f2_public_key, CRYPTO_PUBLIC_KEY_SIZE); | 475 | memcpy(oob_pubkey, f2_public_key, CRYPTO_PUBLIC_KEY_SIZE); |
@@ -475,8 +479,8 @@ START_TEST(test_client) | |||
475 | c_sleep(50); | 479 | c_sleep(50); |
476 | do_TCP_server(tcp_s); | 480 | do_TCP_server(tcp_s); |
477 | c_sleep(50); | 481 | c_sleep(50); |
478 | do_TCP_connection(conn, NULL); | 482 | do_TCP_connection(conn, nullptr); |
479 | do_TCP_connection(conn2, NULL); | 483 | do_TCP_connection(conn2, nullptr); |
480 | ck_assert_msg(oob_data_callback_good == 1, "oob callback not called"); | 484 | ck_assert_msg(oob_data_callback_good == 1, "oob callback not called"); |
481 | ck_assert_msg(response_callback_good == 1, "response callback not called"); | 485 | ck_assert_msg(response_callback_good == 1, "response callback not called"); |
482 | ck_assert_msg(public_key_cmp(response_callback_public_key, f2_public_key) == 0, "wrong public key"); | 486 | ck_assert_msg(public_key_cmp(response_callback_public_key, f2_public_key) == 0, "wrong public key"); |
@@ -489,16 +493,16 @@ START_TEST(test_client) | |||
489 | c_sleep(50); | 493 | c_sleep(50); |
490 | do_TCP_server(tcp_s); | 494 | do_TCP_server(tcp_s); |
491 | c_sleep(50); | 495 | c_sleep(50); |
492 | do_TCP_connection(conn, NULL); | 496 | do_TCP_connection(conn, nullptr); |
493 | do_TCP_connection(conn2, NULL); | 497 | do_TCP_connection(conn2, nullptr); |
494 | ck_assert_msg(data_callback_good == 1, "data callback not called"); | 498 | ck_assert_msg(data_callback_good == 1, "data callback not called"); |
495 | status_callback_good = 0; | 499 | status_callback_good = 0; |
496 | send_disconnect_request(conn2, 0); | 500 | send_disconnect_request(conn2, 0); |
497 | c_sleep(50); | 501 | c_sleep(50); |
498 | do_TCP_server(tcp_s); | 502 | do_TCP_server(tcp_s); |
499 | c_sleep(50); | 503 | c_sleep(50); |
500 | do_TCP_connection(conn, NULL); | 504 | do_TCP_connection(conn, nullptr); |
501 | do_TCP_connection(conn2, NULL); | 505 | do_TCP_connection(conn2, nullptr); |
502 | ck_assert_msg(status_callback_good == 1, "status callback not called"); | 506 | ck_assert_msg(status_callback_good == 1, "status callback not called"); |
503 | ck_assert_msg(status_callback_status == 1, "wrong status"); | 507 | ck_assert_msg(status_callback_status == 1, "wrong status"); |
504 | kill_TCP_server(tcp_s); | 508 | kill_TCP_server(tcp_s); |
@@ -521,17 +525,17 @@ START_TEST(test_client_invalid) | |||
521 | 525 | ||
522 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); | 526 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); |
523 | ip_port_tcp_s.ip = get_loopback(); | 527 | ip_port_tcp_s.ip = get_loopback(); |
524 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, 0); | 528 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr); |
525 | c_sleep(50); | 529 | c_sleep(50); |
526 | do_TCP_connection(conn, NULL); | 530 | do_TCP_connection(conn, nullptr); |
527 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %u, is: %u", | 531 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %u, is: %u", |
528 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); | 532 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); |
529 | c_sleep(5000); | 533 | c_sleep(5000); |
530 | do_TCP_connection(conn, NULL); | 534 | do_TCP_connection(conn, nullptr); |
531 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %u, is: %u", | 535 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %u, is: %u", |
532 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); | 536 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); |
533 | c_sleep(6000); | 537 | c_sleep(6000); |
534 | do_TCP_connection(conn, NULL); | 538 | do_TCP_connection(conn, nullptr); |
535 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %u, is: %u", | 539 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %u, is: %u", |
536 | TCP_CLIENT_DISCONNECTED, tcp_con_status(conn)); | 540 | TCP_CLIENT_DISCONNECTED, tcp_con_status(conn)); |
537 | 541 | ||
@@ -572,7 +576,7 @@ START_TEST(test_tcp_connection) | |||
572 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 576 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
573 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 577 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
574 | crypto_new_keypair(self_public_key, self_secret_key); | 578 | crypto_new_keypair(self_public_key, self_secret_key); |
575 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, NULL); | 579 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
576 | ck_assert_msg(public_key_cmp(tcp_server_public_key(tcp_s), self_public_key) == 0, "Wrong public key"); | 580 | ck_assert_msg(public_key_cmp(tcp_server_public_key(tcp_s), self_public_key) == 0, "Wrong public key"); |
577 | 581 | ||
578 | TCP_Proxy_Info proxy_info; | 582 | TCP_Proxy_Info proxy_info; |
@@ -607,18 +611,18 @@ START_TEST(test_tcp_connection) | |||
607 | c_sleep(50); | 611 | c_sleep(50); |
608 | do_TCP_server(tcp_s); | 612 | do_TCP_server(tcp_s); |
609 | c_sleep(50); | 613 | c_sleep(50); |
610 | do_tcp_connections(tc_1, NULL); | 614 | do_tcp_connections(tc_1, nullptr); |
611 | do_tcp_connections(tc_2, NULL); | 615 | do_tcp_connections(tc_2, nullptr); |
612 | c_sleep(50); | 616 | c_sleep(50); |
613 | do_TCP_server(tcp_s); | 617 | do_TCP_server(tcp_s); |
614 | c_sleep(50); | 618 | c_sleep(50); |
615 | do_tcp_connections(tc_1, NULL); | 619 | do_tcp_connections(tc_1, nullptr); |
616 | do_tcp_connections(tc_2, NULL); | 620 | do_tcp_connections(tc_2, nullptr); |
617 | c_sleep(50); | 621 | c_sleep(50); |
618 | do_TCP_server(tcp_s); | 622 | do_TCP_server(tcp_s); |
619 | c_sleep(50); | 623 | c_sleep(50); |
620 | do_tcp_connections(tc_1, NULL); | 624 | do_tcp_connections(tc_1, nullptr); |
621 | do_tcp_connections(tc_2, NULL); | 625 | do_tcp_connections(tc_2, nullptr); |
622 | 626 | ||
623 | int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6); | 627 | int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6); |
624 | ck_assert_msg(ret == 0, "could not send packet."); | 628 | ck_assert_msg(ret == 0, "could not send packet."); |
@@ -628,8 +632,8 @@ START_TEST(test_tcp_connection) | |||
628 | do_TCP_server(tcp_s); | 632 | do_TCP_server(tcp_s); |
629 | c_sleep(50); | 633 | c_sleep(50); |
630 | 634 | ||
631 | do_tcp_connections(tc_1, NULL); | 635 | do_tcp_connections(tc_1, nullptr); |
632 | do_tcp_connections(tc_2, NULL); | 636 | do_tcp_connections(tc_2, nullptr); |
633 | 637 | ||
634 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); | 638 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); |
635 | ck_assert_msg(tcp_connection_to_online_tcp_relays(tc_1, 0) == 1, "Wrong number of connected relays"); | 639 | ck_assert_msg(tcp_connection_to_online_tcp_relays(tc_1, 0) == 1, "Wrong number of connected relays"); |
@@ -638,8 +642,8 @@ START_TEST(test_tcp_connection) | |||
638 | c_sleep(50); | 642 | c_sleep(50); |
639 | do_TCP_server(tcp_s); | 643 | do_TCP_server(tcp_s); |
640 | c_sleep(50); | 644 | c_sleep(50); |
641 | do_tcp_connections(tc_1, NULL); | 645 | do_tcp_connections(tc_1, nullptr); |
642 | do_tcp_connections(tc_2, NULL); | 646 | do_tcp_connections(tc_2, nullptr); |
643 | 647 | ||
644 | ck_assert_msg(send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6) == -1, "could send packet."); | 648 | ck_assert_msg(send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6) == -1, "could send packet."); |
645 | ck_assert_msg(kill_tcp_connection_to(tc_2, 0) == 0, "could not kill connection to\n"); | 649 | ck_assert_msg(kill_tcp_connection_to(tc_2, 0) == 0, "could not kill connection to\n"); |
@@ -680,7 +684,7 @@ START_TEST(test_tcp_connection2) | |||
680 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 684 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
681 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 685 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
682 | crypto_new_keypair(self_public_key, self_secret_key); | 686 | crypto_new_keypair(self_public_key, self_secret_key); |
683 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, NULL); | 687 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
684 | ck_assert_msg(public_key_cmp(tcp_server_public_key(tcp_s), self_public_key) == 0, "Wrong public key"); | 688 | ck_assert_msg(public_key_cmp(tcp_server_public_key(tcp_s), self_public_key) == 0, "Wrong public key"); |
685 | 689 | ||
686 | TCP_Proxy_Info proxy_info; | 690 | TCP_Proxy_Info proxy_info; |
@@ -709,18 +713,18 @@ START_TEST(test_tcp_connection2) | |||
709 | c_sleep(50); | 713 | c_sleep(50); |
710 | do_TCP_server(tcp_s); | 714 | do_TCP_server(tcp_s); |
711 | c_sleep(50); | 715 | c_sleep(50); |
712 | do_tcp_connections(tc_1, NULL); | 716 | do_tcp_connections(tc_1, nullptr); |
713 | do_tcp_connections(tc_2, NULL); | 717 | do_tcp_connections(tc_2, nullptr); |
714 | c_sleep(50); | 718 | c_sleep(50); |
715 | do_TCP_server(tcp_s); | 719 | do_TCP_server(tcp_s); |
716 | c_sleep(50); | 720 | c_sleep(50); |
717 | do_tcp_connections(tc_1, NULL); | 721 | do_tcp_connections(tc_1, nullptr); |
718 | do_tcp_connections(tc_2, NULL); | 722 | do_tcp_connections(tc_2, nullptr); |
719 | c_sleep(50); | 723 | c_sleep(50); |
720 | do_TCP_server(tcp_s); | 724 | do_TCP_server(tcp_s); |
721 | c_sleep(50); | 725 | c_sleep(50); |
722 | do_tcp_connections(tc_1, NULL); | 726 | do_tcp_connections(tc_1, nullptr); |
723 | do_tcp_connections(tc_2, NULL); | 727 | do_tcp_connections(tc_2, nullptr); |
724 | 728 | ||
725 | int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6); | 729 | int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6); |
726 | ck_assert_msg(ret == 0, "could not send packet."); | 730 | ck_assert_msg(ret == 0, "could not send packet."); |
@@ -731,8 +735,8 @@ START_TEST(test_tcp_connection2) | |||
731 | do_TCP_server(tcp_s); | 735 | do_TCP_server(tcp_s); |
732 | c_sleep(50); | 736 | c_sleep(50); |
733 | 737 | ||
734 | do_tcp_connections(tc_1, NULL); | 738 | do_tcp_connections(tc_1, nullptr); |
735 | do_tcp_connections(tc_2, NULL); | 739 | do_tcp_connections(tc_2, nullptr); |
736 | 740 | ||
737 | ck_assert_msg(tcp_oobdata_callback_called, "could not recv packet."); | 741 | ck_assert_msg(tcp_oobdata_callback_called, "could not recv packet."); |
738 | 742 | ||
@@ -740,8 +744,8 @@ START_TEST(test_tcp_connection2) | |||
740 | do_TCP_server(tcp_s); | 744 | do_TCP_server(tcp_s); |
741 | c_sleep(50); | 745 | c_sleep(50); |
742 | 746 | ||
743 | do_tcp_connections(tc_1, NULL); | 747 | do_tcp_connections(tc_1, nullptr); |
744 | do_tcp_connections(tc_2, NULL); | 748 | do_tcp_connections(tc_2, nullptr); |
745 | 749 | ||
746 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); | 750 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); |
747 | ck_assert_msg(kill_tcp_connection_to(tc_1, 0) == 0, "could not kill connection to\n"); | 751 | ck_assert_msg(kill_tcp_connection_to(tc_1, 0) == 0, "could not kill connection to\n"); |
@@ -767,7 +771,7 @@ static Suite *TCP_suite(void) | |||
767 | 771 | ||
768 | int main(int argc, char *argv[]) | 772 | int main(int argc, char *argv[]) |
769 | { | 773 | { |
770 | srand((unsigned int) time(NULL)); | 774 | srand((unsigned int) time(nullptr)); |
771 | 775 | ||
772 | Suite *TCP = TCP_suite(); | 776 | Suite *TCP = TCP_suite(); |
773 | SRunner *test_runner = srunner_create(TCP); | 777 | SRunner *test_runner = srunner_create(TCP); |
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index 0b3e2e69..1826324e 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c | |||
@@ -1,7 +1,9 @@ | |||
1 | /* Auto Tests: Conferences. | 1 | /* Auto Tests: Conferences. |
2 | */ | 2 | */ |
3 | 3 | ||
4 | #ifndef _XOPEN_SOURCE | ||
4 | #define _XOPEN_SOURCE 600 | 5 | #define _XOPEN_SOURCE 600 |
6 | #endif | ||
5 | 7 | ||
6 | #ifdef HAVE_CONFIG_H | 8 | #ifdef HAVE_CONFIG_H |
7 | #include "config.h" | 9 | #include "config.h" |
@@ -28,7 +30,7 @@ static void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uin | |||
28 | } | 30 | } |
29 | 31 | ||
30 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { | 32 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { |
31 | tox_friend_add_norequest(m, public_key, 0); | 33 | tox_friend_add_norequest(m, public_key, nullptr); |
32 | } | 34 | } |
33 | } | 35 | } |
34 | 36 | ||
@@ -49,12 +51,12 @@ static void print_group_invite_callback(Tox *tox, uint32_t friendnumber, TOX_CON | |||
49 | 51 | ||
50 | uint32_t g_num; | 52 | uint32_t g_num; |
51 | 53 | ||
52 | if ((g_num = tox_conference_join(tox, friendnumber, data, length, NULL)) == UINT32_MAX) { | 54 | if ((g_num = tox_conference_join(tox, friendnumber, data, length, nullptr)) == UINT32_MAX) { |
53 | return; | 55 | return; |
54 | } | 56 | } |
55 | 57 | ||
56 | ck_assert_msg(g_num == 0, "Group number was not 0"); | 58 | ck_assert_msg(g_num == 0, "Group number was not 0"); |
57 | ck_assert_msg(tox_conference_join(tox, friendnumber, data, length, NULL) == -1, | 59 | ck_assert_msg(tox_conference_join(tox, friendnumber, data, length, nullptr) == -1, |
58 | "Joining groupchat twice should be impossible."); | 60 | "Joining groupchat twice should be impossible."); |
59 | 61 | ||
60 | invite_tox = tox; | 62 | invite_tox = tox; |
@@ -78,7 +80,7 @@ static void print_group_message(Tox *tox, uint32_t groupnumber, uint32_t peernum | |||
78 | 80 | ||
79 | START_TEST(test_many_group) | 81 | START_TEST(test_many_group) |
80 | { | 82 | { |
81 | long long unsigned int test_start_time = time(NULL); | 83 | long long unsigned int test_start_time = time(nullptr); |
82 | 84 | ||
83 | group_test_restart: | 85 | group_test_restart: |
84 | ; | 86 | ; |
@@ -88,16 +90,16 @@ group_test_restart: | |||
88 | unsigned int i, j, k; | 90 | unsigned int i, j, k; |
89 | uint32_t to_comp = 234212; | 91 | uint32_t to_comp = 234212; |
90 | int test_run = 0; | 92 | int test_run = 0; |
91 | long long unsigned int cur_time = time(NULL); | 93 | long long unsigned int cur_time = time(nullptr); |
92 | struct Tox_Options *opts = tox_options_new(NULL); | 94 | struct Tox_Options *opts = tox_options_new(nullptr); |
93 | /* FIXME: Currently here is problems with IPv6 */ | 95 | /* FIXME: Currently here is problems with IPv6 */ |
94 | tox_options_set_ipv6_enabled(opts, false); | 96 | tox_options_set_ipv6_enabled(opts, false); |
95 | 97 | ||
96 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 98 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
97 | tox_index[i] = i + 1; | 99 | tox_index[i] = i + 1; |
98 | toxes[i] = tox_new_log(opts, 0, &tox_index[i]); | 100 | toxes[i] = tox_new_log(opts, nullptr, &tox_index[i]); |
99 | 101 | ||
100 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 102 | ck_assert_msg(toxes[i] != nullptr, "Failed to create tox instances %u", i); |
101 | tox_callback_friend_request(toxes[i], &g_accept_friend_request); | 103 | tox_callback_friend_request(toxes[i], &g_accept_friend_request); |
102 | tox_callback_conference_invite(toxes[i], &print_group_invite_callback); | 104 | tox_callback_conference_invite(toxes[i], &print_group_invite_callback); |
103 | } | 105 | } |
@@ -116,14 +118,14 @@ group_test_restart: | |||
116 | tox_self_get_address(toxes[NUM_GROUP_TOX - 1], address); | 118 | tox_self_get_address(toxes[NUM_GROUP_TOX - 1], address); |
117 | 119 | ||
118 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 120 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
119 | ck_assert_msg(tox_friend_add(toxes[i], address, (const uint8_t *)"Gentoo", 7, 0) == 0, "Failed to add friend"); | 121 | ck_assert_msg(tox_friend_add(toxes[i], address, (const uint8_t *)"Gentoo", 7, nullptr) == 0, "Failed to add friend"); |
120 | 122 | ||
121 | tox_self_get_address(toxes[i], address); | 123 | tox_self_get_address(toxes[i], address); |
122 | } | 124 | } |
123 | 125 | ||
124 | while (1) { | 126 | while (1) { |
125 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 127 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
126 | if (tox_friend_get_connection_status(toxes[i], 0, 0) != TOX_CONNECTION_UDP) { | 128 | if (tox_friend_get_connection_status(toxes[i], 0, nullptr) != TOX_CONNECTION_UDP) { |
127 | break; | 129 | break; |
128 | } | 130 | } |
129 | } | 131 | } |
@@ -139,11 +141,11 @@ group_test_restart: | |||
139 | c_sleep(25); | 141 | c_sleep(25); |
140 | } | 142 | } |
141 | 143 | ||
142 | printf("friends connected, took %llu seconds\n", time(NULL) - cur_time); | 144 | printf("friends connected, took %llu seconds\n", time(nullptr) - cur_time); |
143 | 145 | ||
144 | ck_assert_msg(tox_conference_new(toxes[0], NULL) != UINT32_MAX, "Failed to create group"); | 146 | ck_assert_msg(tox_conference_new(toxes[0], nullptr) != UINT32_MAX, "Failed to create group"); |
145 | ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, NULL) != 0, "Failed to invite friend"); | 147 | ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, nullptr) != 0, "Failed to invite friend"); |
146 | ck_assert_msg(tox_conference_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1, NULL) != 0, | 148 | ck_assert_msg(tox_conference_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1, nullptr) != 0, |
147 | "Failed to set group title"); | 149 | "Failed to set group title"); |
148 | invite_counter = ~0; | 150 | invite_counter = ~0; |
149 | 151 | ||
@@ -156,7 +158,7 @@ group_test_restart: | |||
156 | } | 158 | } |
157 | 159 | ||
158 | if (!invite_counter) { | 160 | if (!invite_counter) { |
159 | ck_assert_msg(tox_conference_invite(invite_tox, 0, 0, NULL) != 0, "Failed to invite friend"); | 161 | ck_assert_msg(tox_conference_invite(invite_tox, 0, 0, nullptr) != 0, "Failed to invite friend"); |
160 | } | 162 | } |
161 | 163 | ||
162 | if (done == invite_counter) { | 164 | if (done == invite_counter) { |
@@ -168,7 +170,7 @@ group_test_restart: | |||
168 | } | 170 | } |
169 | 171 | ||
170 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 172 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
171 | uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, NULL); | 173 | uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, nullptr); |
172 | 174 | ||
173 | /** | 175 | /** |
174 | * Group chats fail unpredictably, currently they'll rerun as many times | 176 | * Group chats fail unpredictably, currently they'll rerun as many times |
@@ -199,9 +201,9 @@ group_test_restart: | |||
199 | NUM_GROUP_TOX, i, peer_count); | 201 | NUM_GROUP_TOX, i, peer_count); |
200 | 202 | ||
201 | uint8_t title[2048]; | 203 | uint8_t title[2048]; |
202 | size_t ret = tox_conference_get_title_size(toxes[i], 0, NULL); | 204 | size_t ret = tox_conference_get_title_size(toxes[i], 0, nullptr); |
203 | ck_assert_msg(ret == sizeof("Gentoo") - 1, "Wrong title length"); | 205 | ck_assert_msg(ret == sizeof("Gentoo") - 1, "Wrong title length"); |
204 | tox_conference_get_title(toxes[i], 0, title, NULL); | 206 | tox_conference_get_title(toxes[i], 0, title, nullptr); |
205 | ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title"); | 207 | ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title"); |
206 | } | 208 | } |
207 | 209 | ||
@@ -232,7 +234,7 @@ group_test_restart: | |||
232 | ck_assert_msg(num_recv == NUM_GROUP_TOX, "Failed to recv group messages."); | 234 | ck_assert_msg(num_recv == NUM_GROUP_TOX, "Failed to recv group messages."); |
233 | 235 | ||
234 | for (k = NUM_GROUP_TOX; k != 0 ; --k) { | 236 | for (k = NUM_GROUP_TOX; k != 0 ; --k) { |
235 | tox_conference_delete(toxes[k - 1], 0, NULL); | 237 | tox_conference_delete(toxes[k - 1], 0, nullptr); |
236 | 238 | ||
237 | for (j = 0; j < 10; ++j) { | 239 | for (j = 0; j < 10; ++j) { |
238 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 240 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
@@ -243,7 +245,7 @@ group_test_restart: | |||
243 | } | 245 | } |
244 | 246 | ||
245 | for (i = 0; i < (k - 1); ++i) { | 247 | for (i = 0; i < (k - 1); ++i) { |
246 | uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, NULL); | 248 | uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, nullptr); |
247 | ck_assert_msg(peer_count == (k - 1), "\n\tBad number of group peers (post check)." | 249 | ck_assert_msg(peer_count == (k - 1), "\n\tBad number of group peers (post check)." |
248 | "\n\t\t\tExpected: %u but tox_instance(%u) only has: %" PRIu32 "\n\n", | 250 | "\n\t\t\tExpected: %u but tox_instance(%u) only has: %" PRIu32 "\n\n", |
249 | (k - 1), i, peer_count); | 251 | (k - 1), i, peer_count); |
@@ -254,7 +256,7 @@ group_test_restart: | |||
254 | tox_kill(toxes[i]); | 256 | tox_kill(toxes[i]); |
255 | } | 257 | } |
256 | 258 | ||
257 | printf("test_many_group succeeded, took %llu seconds\n", time(NULL) - test_start_time); | 259 | printf("test_many_group succeeded, took %llu seconds\n", time(nullptr) - test_start_time); |
258 | } | 260 | } |
259 | END_TEST | 261 | END_TEST |
260 | 262 | ||
@@ -275,7 +277,7 @@ static Suite *tox_suite(void) | |||
275 | 277 | ||
276 | int main(int argc, char *argv[]) | 278 | int main(int argc, char *argv[]) |
277 | { | 279 | { |
278 | srand((unsigned int) time(NULL)); | 280 | srand((unsigned int) time(nullptr)); |
279 | 281 | ||
280 | Suite *tox = tox_suite(); | 282 | Suite *tox = tox_suite(); |
281 | SRunner *test_runner = srunner_create(tox); | 283 | SRunner *test_runner = srunner_create(tox); |
diff --git a/auto_tests/crypto_test.c b/auto_tests/crypto_test.c index 5f162499..a1b7fd30 100644 --- a/auto_tests/crypto_test.c +++ b/auto_tests/crypto_test.c | |||
@@ -434,7 +434,7 @@ static Suite *crypto_suite(void) | |||
434 | 434 | ||
435 | int main(int argc, char *argv[]) | 435 | int main(int argc, char *argv[]) |
436 | { | 436 | { |
437 | srand((unsigned int) time(NULL)); | 437 | srand((unsigned int) time(nullptr)); |
438 | 438 | ||
439 | Suite *crypto = crypto_suite(); | 439 | Suite *crypto = crypto_suite(); |
440 | SRunner *test_runner = srunner_create(crypto); | 440 | SRunner *test_runner = srunner_create(crypto); |
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index c426d3e8..227b43f7 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #ifndef _XOPEN_SOURCE | ||
1 | #define _XOPEN_SOURCE 600 | 2 | #define _XOPEN_SOURCE 600 |
3 | #endif | ||
2 | 4 | ||
3 | #ifdef HAVE_CONFIG_H | 5 | #ifdef HAVE_CONFIG_H |
4 | #include "config.h" | 6 | #include "config.h" |
@@ -11,7 +13,9 @@ | |||
11 | 13 | ||
12 | #include "helpers.h" | 14 | #include "helpers.h" |
13 | 15 | ||
16 | #ifndef DHT_C_INCLUDED | ||
14 | #include "../toxcore/DHT.c" | 17 | #include "../toxcore/DHT.c" |
18 | #endif // DHT_C_INCLUDED | ||
15 | #include "../toxcore/tox.h" | 19 | #include "../toxcore/tox.h" |
16 | 20 | ||
17 | 21 | ||
@@ -325,11 +329,11 @@ static void test_addto_lists_good(DHT *dht, | |||
325 | 329 | ||
326 | static void test_addto_lists(IP ip) | 330 | static void test_addto_lists(IP ip) |
327 | { | 331 | { |
328 | Networking_Core *net = new_networking(NULL, ip, TOX_PORT_DEFAULT); | 332 | Networking_Core *net = new_networking(nullptr, ip, TOX_PORT_DEFAULT); |
329 | ck_assert_msg(net != 0, "Failed to create Networking_Core"); | 333 | ck_assert_msg(net != nullptr, "Failed to create Networking_Core"); |
330 | 334 | ||
331 | DHT *dht = new_DHT(NULL, net, true); | 335 | DHT *dht = new_DHT(nullptr, net, true); |
332 | ck_assert_msg(dht != 0, "Failed to create DHT"); | 336 | ck_assert_msg(dht != nullptr, "Failed to create DHT"); |
333 | 337 | ||
334 | IP_Port ip_port = { .ip = ip, .port = TOX_PORT_DEFAULT }; | 338 | IP_Port ip_port = { .ip = ip, .port = TOX_PORT_DEFAULT }; |
335 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 339 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
@@ -466,8 +470,8 @@ static void test_list_main(void) | |||
466 | IP ip; | 470 | IP ip; |
467 | ip_init(&ip, 1); | 471 | ip_init(&ip, 1); |
468 | 472 | ||
469 | dhts[i] = new_DHT(NULL, new_networking(NULL, ip, DHT_DEFAULT_PORT + i), true); | 473 | dhts[i] = new_DHT(nullptr, new_networking(nullptr, ip, DHT_DEFAULT_PORT + i), true); |
470 | ck_assert_msg(dhts[i] != 0, "Failed to create dht instances %u", i); | 474 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); |
471 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); | 475 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); |
472 | } | 476 | } |
473 | 477 | ||
@@ -602,8 +606,8 @@ START_TEST(test_DHT_test) | |||
602 | IP ip; | 606 | IP ip; |
603 | ip_init(&ip, 1); | 607 | ip_init(&ip, 1); |
604 | 608 | ||
605 | dhts[i] = new_DHT(NULL, new_networking(NULL, ip, DHT_DEFAULT_PORT + i), true); | 609 | dhts[i] = new_DHT(nullptr, new_networking(nullptr, ip, DHT_DEFAULT_PORT + i), true); |
606 | ck_assert_msg(dhts[i] != 0, "Failed to create dht instances %u", i); | 610 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); |
607 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); | 611 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); |
608 | } | 612 | } |
609 | 613 | ||
@@ -652,7 +656,7 @@ loop_top: | |||
652 | } | 656 | } |
653 | 657 | ||
654 | for (i = 0; i < NUM_DHT; ++i) { | 658 | for (i = 0; i < NUM_DHT; ++i) { |
655 | networking_poll(dhts[i]->net, NULL); | 659 | networking_poll(dhts[i]->net, nullptr); |
656 | do_DHT(dhts[i]); | 660 | do_DHT(dhts[i]); |
657 | } | 661 | } |
658 | 662 | ||
@@ -715,7 +719,7 @@ static void dht_pack_unpack(const Node_format *nodes, size_t size, uint8_t *data | |||
715 | 719 | ||
716 | static void random_ip(IP_Port *ipp, int family) | 720 | static void random_ip(IP_Port *ipp, int family) |
717 | { | 721 | { |
718 | uint8_t *ip = NULL; | 722 | uint8_t *ip = nullptr; |
719 | size_t size; | 723 | size_t size; |
720 | 724 | ||
721 | if (family == TOX_AF_INET || family == TCP_INET) { | 725 | if (family == TOX_AF_INET || family == TCP_INET) { |
@@ -797,7 +801,7 @@ static Suite *dht_suite(void) | |||
797 | 801 | ||
798 | int main(int argc, char *argv[]) | 802 | int main(int argc, char *argv[]) |
799 | { | 803 | { |
800 | srand((unsigned int) time(NULL)); | 804 | srand((unsigned int) time(nullptr)); |
801 | 805 | ||
802 | Suite *dht = dht_suite(); | 806 | Suite *dht = dht_suite(); |
803 | SRunner *test_runner = srunner_create(dht); | 807 | SRunner *test_runner = srunner_create(dht); |
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index 7442d4fc..61b00992 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c | |||
@@ -39,7 +39,7 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
39 | } | 39 | } |
40 | 40 | ||
41 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { | 41 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { |
42 | tox_friend_add_norequest(m, public_key, 0); | 42 | tox_friend_add_norequest(m, public_key, nullptr); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
@@ -60,13 +60,13 @@ END_TEST | |||
60 | 60 | ||
61 | START_TEST(test_save_friend) | 61 | START_TEST(test_save_friend) |
62 | { | 62 | { |
63 | Tox *tox1 = tox_new_log(0, 0, 0); | 63 | Tox *tox1 = tox_new_log(nullptr, nullptr, nullptr); |
64 | Tox *tox2 = tox_new_log(0, 0, 0); | 64 | Tox *tox2 = tox_new_log(nullptr, nullptr, nullptr); |
65 | ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances"); | 65 | ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances"); |
66 | tox_callback_friend_request(tox2, accept_friend_request); | 66 | tox_callback_friend_request(tox2, accept_friend_request); |
67 | uint8_t address[TOX_ADDRESS_SIZE]; | 67 | uint8_t address[TOX_ADDRESS_SIZE]; |
68 | tox_self_get_address(tox2, address); | 68 | tox_self_get_address(tox2, address); |
69 | uint32_t test = tox_friend_add(tox1, address, (const uint8_t *)"Gentoo", 7, 0); | 69 | uint32_t test = tox_friend_add(tox1, address, (const uint8_t *)"Gentoo", 7, nullptr); |
70 | ck_assert_msg(test != UINT32_MAX, "Failed to add friend"); | 70 | ck_assert_msg(test != UINT32_MAX, "Failed to add friend"); |
71 | 71 | ||
72 | size_t size = tox_get_savedata_size(tox1); | 72 | size_t size = tox_get_savedata_size(tox1); |
@@ -79,24 +79,24 @@ START_TEST(test_save_friend) | |||
79 | ck_assert_msg(ret, "failed to encrypted save: %u", error1); | 79 | ck_assert_msg(ret, "failed to encrypted save: %u", error1); |
80 | ck_assert_msg(tox_is_data_encrypted(enc_data), "magic number missing"); | 80 | ck_assert_msg(tox_is_data_encrypted(enc_data), "magic number missing"); |
81 | 81 | ||
82 | struct Tox_Options *options = tox_options_new(NULL); | 82 | struct Tox_Options *options = tox_options_new(nullptr); |
83 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); | 83 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); |
84 | tox_options_set_savedata_data(options, enc_data, size2); | 84 | tox_options_set_savedata_data(options, enc_data, size2); |
85 | 85 | ||
86 | TOX_ERR_NEW err2; | 86 | TOX_ERR_NEW err2; |
87 | Tox *tox3 = tox_new_log(options, &err2, 0); | 87 | Tox *tox3 = tox_new_log(options, &err2, nullptr); |
88 | ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %u", err2, | 88 | ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %u", err2, |
89 | TOX_ERR_NEW_LOAD_ENCRYPTED); | 89 | TOX_ERR_NEW_LOAD_ENCRYPTED); |
90 | ck_assert_msg(tox3 == NULL, "tox_new with error should return NULL"); | 90 | ck_assert_msg(tox3 == nullptr, "tox_new with error should return NULL"); |
91 | VLA(uint8_t, dec_data, size); | 91 | VLA(uint8_t, dec_data, size); |
92 | TOX_ERR_DECRYPTION err3; | 92 | TOX_ERR_DECRYPTION err3; |
93 | ret = tox_pass_decrypt(enc_data, size2, (const uint8_t *)"correcthorsebatterystaple", 25, dec_data, &err3); | 93 | ret = tox_pass_decrypt(enc_data, size2, (const uint8_t *)"correcthorsebatterystaple", 25, dec_data, &err3); |
94 | ck_assert_msg(ret, "failed to decrypt save: %u", err3); | 94 | ck_assert_msg(ret, "failed to decrypt save: %u", err3); |
95 | tox_options_set_savedata_data(options, dec_data, size); | 95 | tox_options_set_savedata_data(options, dec_data, size); |
96 | tox3 = tox_new_log(options, &err2, 0); | 96 | tox3 = tox_new_log(options, &err2, nullptr); |
97 | ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %u", err2); | 97 | ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %u", err2); |
98 | uint8_t address2[TOX_PUBLIC_KEY_SIZE]; | 98 | uint8_t address2[TOX_PUBLIC_KEY_SIZE]; |
99 | ret = tox_friend_get_public_key(tox3, 0, address2, 0); | 99 | ret = tox_friend_get_public_key(tox3, 0, address2, nullptr); |
100 | ck_assert_msg(ret, "no friends!"); | 100 | ck_assert_msg(ret, "no friends!"); |
101 | ck_assert_msg(memcmp(address, address2, TOX_PUBLIC_KEY_SIZE) == 0, "addresses don't match!"); | 101 | ck_assert_msg(memcmp(address, address2, TOX_PUBLIC_KEY_SIZE) == 0, "addresses don't match!"); |
102 | 102 | ||
@@ -105,7 +105,7 @@ START_TEST(test_save_friend) | |||
105 | tox_get_savedata(tox3, data2); | 105 | tox_get_savedata(tox3, data2); |
106 | TOX_ERR_KEY_DERIVATION keyerr; | 106 | TOX_ERR_KEY_DERIVATION keyerr; |
107 | Tox_Pass_Key *key = tox_pass_key_derive((const uint8_t *)"123qweasdzxc", 12, &keyerr); | 107 | Tox_Pass_Key *key = tox_pass_key_derive((const uint8_t *)"123qweasdzxc", 12, &keyerr); |
108 | ck_assert_msg(key != NULL, "pass key allocation failure"); | 108 | ck_assert_msg(key != nullptr, "pass key allocation failure"); |
109 | memcpy((uint8_t *)key, test_salt, TOX_PASS_SALT_LENGTH); | 109 | memcpy((uint8_t *)key, test_salt, TOX_PASS_SALT_LENGTH); |
110 | memcpy((uint8_t *)key + TOX_PASS_SALT_LENGTH, known_key2, TOX_PASS_KEY_LENGTH); | 110 | memcpy((uint8_t *)key + TOX_PASS_SALT_LENGTH, known_key2, TOX_PASS_KEY_LENGTH); |
111 | size2 = size + TOX_PASS_ENCRYPTION_EXTRA_LENGTH; | 111 | size2 = size + TOX_PASS_ENCRYPTION_EXTRA_LENGTH; |
@@ -125,10 +125,10 @@ START_TEST(test_save_friend) | |||
125 | // and now with the code in use (I only bothered with manually to debug this, and it seems a waste | 125 | // and now with the code in use (I only bothered with manually to debug this, and it seems a waste |
126 | // to remove the manual check now that it's there) | 126 | // to remove the manual check now that it's there) |
127 | tox_options_set_savedata_data(options, out1, size); | 127 | tox_options_set_savedata_data(options, out1, size); |
128 | Tox *tox4 = tox_new_log(options, &err2, 0); | 128 | Tox *tox4 = tox_new_log(options, &err2, nullptr); |
129 | ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to new the third"); | 129 | ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to new the third"); |
130 | uint8_t address5[TOX_PUBLIC_KEY_SIZE]; | 130 | uint8_t address5[TOX_PUBLIC_KEY_SIZE]; |
131 | ret = tox_friend_get_public_key(tox4, 0, address5, 0); | 131 | ret = tox_friend_get_public_key(tox4, 0, address5, nullptr); |
132 | ck_assert_msg(ret, "no friends! the third"); | 132 | ck_assert_msg(ret, "no friends! the third"); |
133 | ck_assert_msg(memcmp(address, address2, TOX_PUBLIC_KEY_SIZE) == 0, "addresses don't match! the third"); | 133 | ck_assert_msg(memcmp(address, address2, TOX_PUBLIC_KEY_SIZE) == 0, "addresses don't match! the third"); |
134 | 134 | ||
@@ -148,7 +148,7 @@ START_TEST(test_keys) | |||
148 | TOX_ERR_DECRYPTION decerr; | 148 | TOX_ERR_DECRYPTION decerr; |
149 | TOX_ERR_KEY_DERIVATION keyerr; | 149 | TOX_ERR_KEY_DERIVATION keyerr; |
150 | Tox_Pass_Key *key = tox_pass_key_derive((const uint8_t *)"123qweasdzxc", 12, &keyerr); | 150 | Tox_Pass_Key *key = tox_pass_key_derive((const uint8_t *)"123qweasdzxc", 12, &keyerr); |
151 | ck_assert_msg(key != NULL, "generic failure 1: %u", keyerr); | 151 | ck_assert_msg(key != nullptr, "generic failure 1: %u", keyerr); |
152 | const uint8_t *string = (const uint8_t *)"No Patrick, mayonnaise is not an instrument."; // 44 | 152 | const uint8_t *string = (const uint8_t *)"No Patrick, mayonnaise is not an instrument."; // 44 |
153 | 153 | ||
154 | uint8_t encrypted[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH]; | 154 | uint8_t encrypted[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH]; |
@@ -171,7 +171,7 @@ START_TEST(test_keys) | |||
171 | ck_assert_msg(ret, "generic failure 5: %u", decerr); | 171 | ck_assert_msg(ret, "generic failure 5: %u", decerr); |
172 | ck_assert_msg(memcmp(out2, string, 44) == 0, "decryption 2 failed"); | 172 | ck_assert_msg(memcmp(out2, string, 44) == 0, "decryption 2 failed"); |
173 | 173 | ||
174 | ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, NULL, 0, out2, &decerr); | 174 | ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, nullptr, 0, out2, &decerr); |
175 | ck_assert_msg(!ret, "Decrypt succeeded with wrong pass"); | 175 | ck_assert_msg(!ret, "Decrypt succeeded with wrong pass"); |
176 | ck_assert_msg(decerr != TOX_ERR_DECRYPTION_FAILED, "Bad error code %u", decerr); | 176 | ck_assert_msg(decerr != TOX_ERR_DECRYPTION_FAILED, "Bad error code %u", decerr); |
177 | 177 | ||
@@ -186,7 +186,7 @@ START_TEST(test_keys) | |||
186 | ck_assert_msg(tox_get_salt(encrypted, salt, &salt_err), "couldn't get salt"); | 186 | ck_assert_msg(tox_get_salt(encrypted, salt, &salt_err), "couldn't get salt"); |
187 | ck_assert_msg(salt_err == TOX_ERR_GET_SALT_OK, "get_salt returned an error"); | 187 | ck_assert_msg(salt_err == TOX_ERR_GET_SALT_OK, "get_salt returned an error"); |
188 | Tox_Pass_Key *key2 = tox_pass_key_derive_with_salt((const uint8_t *)"123qweasdzxc", 12, salt, &keyerr); | 188 | Tox_Pass_Key *key2 = tox_pass_key_derive_with_salt((const uint8_t *)"123qweasdzxc", 12, salt, &keyerr); |
189 | ck_assert_msg(key2 != NULL, "generic failure 7: %u", keyerr); | 189 | ck_assert_msg(key2 != nullptr, "generic failure 7: %u", keyerr); |
190 | ck_assert_msg(0 == memcmp(key, key2, TOX_PASS_KEY_LENGTH + TOX_PASS_SALT_LENGTH), "salt comparison failed"); | 190 | ck_assert_msg(0 == memcmp(key, key2, TOX_PASS_KEY_LENGTH + TOX_PASS_SALT_LENGTH), "salt comparison failed"); |
191 | tox_pass_key_free(key2); | 191 | tox_pass_key_free(key2); |
192 | tox_pass_key_free(key); | 192 | tox_pass_key_free(key); |
@@ -206,7 +206,7 @@ static Suite *encryptsave_suite(void) | |||
206 | 206 | ||
207 | int main(int argc, char *argv[]) | 207 | int main(int argc, char *argv[]) |
208 | { | 208 | { |
209 | srand((unsigned int) time(NULL)); | 209 | srand((unsigned int) time(nullptr)); |
210 | 210 | ||
211 | Suite *encryptsave = encryptsave_suite(); | 211 | Suite *encryptsave = encryptsave_suite(); |
212 | SRunner *test_runner = srunner_create(encryptsave); | 212 | SRunner *test_runner = srunner_create(encryptsave); |
diff --git a/auto_tests/file_saving_test.c b/auto_tests/file_saving_test.c index 8c3f10d4..5ed74c9f 100644 --- a/auto_tests/file_saving_test.c +++ b/auto_tests/file_saving_test.c | |||
@@ -30,15 +30,17 @@ | |||
30 | #include "../toxcore/tox.h" | 30 | #include "../toxcore/tox.h" |
31 | #include "../toxencryptsave/toxencryptsave.h" | 31 | #include "../toxencryptsave/toxencryptsave.h" |
32 | 32 | ||
33 | #include "../toxcore/ccompat.h" | ||
34 | |||
33 | static const char *pphrase = "bar", *name = "foo", *savefile = "./save"; | 35 | static const char *pphrase = "bar", *name = "foo", *savefile = "./save"; |
34 | 36 | ||
35 | static void save_data_encrypted(void) | 37 | static void save_data_encrypted(void) |
36 | { | 38 | { |
37 | struct Tox_Options *options = tox_options_new(NULL); | 39 | struct Tox_Options *options = tox_options_new(nullptr); |
38 | Tox *t = tox_new(options, NULL); | 40 | Tox *t = tox_new(options, nullptr); |
39 | tox_options_free(options); | 41 | tox_options_free(options); |
40 | 42 | ||
41 | tox_self_set_name(t, (const uint8_t *)name, strlen(name), NULL); | 43 | tox_self_set_name(t, (const uint8_t *)name, strlen(name), nullptr); |
42 | 44 | ||
43 | FILE *f = fopen(savefile, "w"); | 45 | FILE *f = fopen(savefile, "w"); |
44 | 46 | ||
@@ -87,7 +89,7 @@ static void load_data_decrypted(void) | |||
87 | exit(3); | 89 | exit(3); |
88 | } | 90 | } |
89 | 91 | ||
90 | struct Tox_Options *options = tox_options_new(NULL); | 92 | struct Tox_Options *options = tox_options_new(nullptr); |
91 | 93 | ||
92 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); | 94 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); |
93 | 95 | ||
@@ -99,7 +101,7 @@ static void load_data_decrypted(void) | |||
99 | 101 | ||
100 | tox_options_free(options); | 102 | tox_options_free(options); |
101 | 103 | ||
102 | if (t == NULL) { | 104 | if (t == nullptr) { |
103 | fprintf(stderr, "error: tox_new returned the error value %d\n", err); | 105 | fprintf(stderr, "error: tox_new returned the error value %d\n", err); |
104 | return; | 106 | return; |
105 | } | 107 | } |
diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h index 373b4a37..7b6146a4 100644 --- a/auto_tests/helpers.h +++ b/auto_tests/helpers.h | |||
@@ -3,6 +3,8 @@ | |||
3 | 3 | ||
4 | #include "../toxcore/tox.h" | 4 | #include "../toxcore/tox.h" |
5 | 5 | ||
6 | #include "../toxcore/ccompat.h" | ||
7 | |||
6 | #include <assert.h> | 8 | #include <assert.h> |
7 | #include <stdio.h> | 9 | #include <stdio.h> |
8 | #include <string.h> | 10 | #include <string.h> |
@@ -67,17 +69,17 @@ Tox *tox_new_log(struct Tox_Options *options, TOX_ERR_NEW *err, void *log_user_d | |||
67 | { | 69 | { |
68 | struct Tox_Options *log_options = options; | 70 | struct Tox_Options *log_options = options; |
69 | 71 | ||
70 | if (log_options == NULL) { | 72 | if (log_options == nullptr) { |
71 | log_options = tox_options_new(NULL); | 73 | log_options = tox_options_new(nullptr); |
72 | } | 74 | } |
73 | 75 | ||
74 | assert(log_options != NULL); | 76 | assert(log_options != nullptr); |
75 | 77 | ||
76 | tox_options_set_log_callback(log_options, &print_debug_log); | 78 | tox_options_set_log_callback(log_options, &print_debug_log); |
77 | tox_options_set_log_user_data(log_options, log_user_data); | 79 | tox_options_set_log_user_data(log_options, log_user_data); |
78 | Tox *tox = tox_new(log_options, err); | 80 | Tox *tox = tox_new(log_options, err); |
79 | 81 | ||
80 | if (options == NULL) { | 82 | if (options == nullptr) { |
81 | tox_options_free(log_options); | 83 | tox_options_free(log_options); |
82 | } | 84 | } |
83 | 85 | ||
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index 8ab185a0..34de6543 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -44,10 +44,10 @@ static const char *good_id_b_str = "d3f14b6d384d8f5f2a66cff637e69f28f539c5de61bc | |||
44 | 44 | ||
45 | static const char *bad_id_str = "9B569D14ff637e69f2"; | 45 | static const char *bad_id_str = "9B569D14ff637e69f2"; |
46 | 46 | ||
47 | static unsigned char *friend_id = NULL; | 47 | static unsigned char *friend_id = nullptr; |
48 | static unsigned char *good_id_a = NULL; | 48 | static unsigned char *good_id_a = nullptr; |
49 | static unsigned char *good_id_b = NULL; | 49 | static unsigned char *good_id_b = nullptr; |
50 | static unsigned char *bad_id = NULL; | 50 | static unsigned char *bad_id = nullptr; |
51 | 51 | ||
52 | static int friend_id_num = 0; | 52 | static int friend_id_num = 0; |
53 | 53 | ||
@@ -60,10 +60,14 @@ START_TEST(test_m_sendmesage) | |||
60 | int bad_len = MAX_CRYPTO_PACKET_SIZE; | 60 | int bad_len = MAX_CRYPTO_PACKET_SIZE; |
61 | 61 | ||
62 | 62 | ||
63 | ck_assert(m_send_message_generic(m, -1, MESSAGE_NORMAL, (const uint8_t *)message, good_len, 0) == -1); | 63 | ck_assert(m_send_message_generic( |
64 | ck_assert(m_send_message_generic(m, REALLY_BIG_NUMBER, MESSAGE_NORMAL, (const uint8_t *)message, good_len, 0) == -1); | 64 | m, -1, MESSAGE_NORMAL, (const uint8_t *)message, good_len, nullptr) == -1); |
65 | ck_assert(m_send_message_generic(m, 17, MESSAGE_NORMAL, (const uint8_t *)message, good_len, 0) == -1); | 65 | ck_assert(m_send_message_generic( |
66 | ck_assert(m_send_message_generic(m, friend_id_num, MESSAGE_NORMAL, (const uint8_t *)message, bad_len, 0) == -2); | 66 | m, REALLY_BIG_NUMBER, MESSAGE_NORMAL, (const uint8_t *)message, good_len, nullptr) == -1); |
67 | ck_assert(m_send_message_generic( | ||
68 | m, 17, MESSAGE_NORMAL, (const uint8_t *)message, good_len, nullptr) == -1); | ||
69 | ck_assert(m_send_message_generic( | ||
70 | m, friend_id_num, MESSAGE_NORMAL, (const uint8_t *)message, bad_len, nullptr) == -2); | ||
67 | } | 71 | } |
68 | END_TEST | 72 | END_TEST |
69 | 73 | ||
@@ -355,7 +359,7 @@ int main(int argc, char *argv[]) | |||
355 | Messenger_Options options = {0}; | 359 | Messenger_Options options = {0}; |
356 | options.ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; | 360 | options.ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; |
357 | options.log_callback = (logger_cb *)print_debug_log; | 361 | options.log_callback = (logger_cb *)print_debug_log; |
358 | m = new_messenger(&options, 0); | 362 | m = new_messenger(&options, nullptr); |
359 | 363 | ||
360 | /* setup a default friend and friendnum */ | 364 | /* setup a default friend and friendnum */ |
361 | if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) { | 365 | if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) { |
diff --git a/auto_tests/monolith_test.cpp b/auto_tests/monolith_test.cpp index 253d2bd3..cc8150ef 100644 --- a/auto_tests/monolith_test.cpp +++ b/auto_tests/monolith_test.cpp | |||
@@ -9,6 +9,83 @@ | |||
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #include "../other/monolith.h" | 11 | #include "../other/monolith.h" |
12 | #define DHT_C_INCLUDED | ||
13 | |||
14 | #include "check_compat.h" | ||
15 | #include "helpers.h" | ||
16 | #include "../testing/misc_tools.c" | ||
17 | |||
18 | #include <ctype.h> | ||
19 | |||
20 | namespace TCP_test { | ||
21 | #include "TCP_test.c" | ||
22 | } | ||
23 | namespace conference_test { | ||
24 | #include "conference_test.c" | ||
25 | } | ||
26 | namespace crypto_test { | ||
27 | #include "crypto_test.c" | ||
28 | } | ||
29 | namespace dht_test { | ||
30 | #include "dht_test.c" | ||
31 | } | ||
32 | namespace encryptsave_test { | ||
33 | #include "encryptsave_test.c" | ||
34 | } | ||
35 | namespace file_saving_test { | ||
36 | #include "file_saving_test.c" | ||
37 | } | ||
38 | namespace messenger_test { | ||
39 | #include "messenger_test.c" | ||
40 | } | ||
41 | namespace network_test { | ||
42 | #include "network_test.c" | ||
43 | } | ||
44 | namespace onion_test { | ||
45 | #include "onion_test.c" | ||
46 | } | ||
47 | namespace resource_leak_test { | ||
48 | #include "resource_leak_test.c" | ||
49 | } | ||
50 | namespace save_friend_test { | ||
51 | #include "save_friend_test.c" | ||
52 | } | ||
53 | namespace selfname_change_conference_test { | ||
54 | #include "selfname_change_conference_test.c" | ||
55 | } | ||
56 | namespace self_conference_title_change_test { | ||
57 | #include "self_conference_title_change_test.c" | ||
58 | } | ||
59 | namespace simple_conference_test { | ||
60 | #include "simple_conference_test.c" | ||
61 | } | ||
62 | namespace skeleton_test { | ||
63 | #include "skeleton_test.c" | ||
64 | } | ||
65 | namespace toxav_basic_test { | ||
66 | #include "toxav_basic_test.c" | ||
67 | } | ||
68 | namespace toxav_many_test { | ||
69 | #include "toxav_many_test.c" | ||
70 | } | ||
71 | namespace tox_many_tcp_test { | ||
72 | #include "tox_many_tcp_test.c" | ||
73 | } | ||
74 | namespace tox_many_test { | ||
75 | #include "tox_many_test.c" | ||
76 | } | ||
77 | namespace tox_one_test { | ||
78 | #include "tox_one_test.c" | ||
79 | } | ||
80 | namespace tox_strncasecmp_test { | ||
81 | #include "tox_strncasecmp_test.c" | ||
82 | } | ||
83 | namespace tox_test { | ||
84 | #include "tox_test.c" | ||
85 | } | ||
86 | namespace version_test { | ||
87 | #include "version_test.c" | ||
88 | } | ||
12 | 89 | ||
13 | int main(int argc, char *argv[]) | 90 | int main(int argc, char *argv[]) |
14 | { | 91 | { |
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c index 106f5f6a..9e3e0e15 100644 --- a/auto_tests/network_test.c +++ b/auto_tests/network_test.c | |||
@@ -36,7 +36,7 @@ START_TEST(test_addr_resolv_localhost) | |||
36 | IP ip; | 36 | IP ip; |
37 | ip_init(&ip, 0); // ipv6enabled = 0 | 37 | ip_init(&ip, 0); // ipv6enabled = 0 |
38 | 38 | ||
39 | int res = addr_resolve(localhost, &ip, NULL); | 39 | int res = addr_resolve(localhost, &ip, nullptr); |
40 | 40 | ||
41 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); | 41 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); |
42 | 42 | ||
@@ -47,10 +47,10 @@ START_TEST(test_addr_resolv_localhost) | |||
47 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 47 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
48 | 48 | ||
49 | ip_init(&ip, 1); // ipv6enabled = 1 | 49 | ip_init(&ip, 1); // ipv6enabled = 1 |
50 | res = addr_resolve(localhost, &ip, NULL); | 50 | res = addr_resolve(localhost, &ip, nullptr); |
51 | 51 | ||
52 | if (!(res & TOX_ADDR_RESOLVE_INET6)) { | 52 | if (!(res & TOX_ADDR_RESOLVE_INET6)) { |
53 | res = addr_resolve("ip6-localhost", &ip, NULL); | 53 | res = addr_resolve("ip6-localhost", &ip, nullptr); |
54 | localhost_split = 1; | 54 | localhost_split = 1; |
55 | } | 55 | } |
56 | 56 | ||
@@ -96,13 +96,13 @@ START_TEST(test_ip_equal) | |||
96 | ip_reset(&ip1); | 96 | ip_reset(&ip1); |
97 | ip_reset(&ip2); | 97 | ip_reset(&ip2); |
98 | 98 | ||
99 | res = ip_equal(NULL, NULL); | 99 | res = ip_equal(nullptr, nullptr); |
100 | ck_assert_msg(res == 0, "ip_equal(NULL, NULL): expected result 0, got %u.", res); | 100 | ck_assert_msg(res == 0, "ip_equal(NULL, NULL): expected result 0, got %u.", res); |
101 | 101 | ||
102 | res = ip_equal(&ip1, NULL); | 102 | res = ip_equal(&ip1, nullptr); |
103 | ck_assert_msg(res == 0, "ip_equal(PTR, NULL): expected result 0, got %u.", res); | 103 | ck_assert_msg(res == 0, "ip_equal(PTR, NULL): expected result 0, got %u.", res); |
104 | 104 | ||
105 | res = ip_equal(NULL, &ip1); | 105 | res = ip_equal(nullptr, &ip1); |
106 | ck_assert_msg(res == 0, "ip_equal(NULL, PTR): expected result 0, got %u.", res); | 106 | ck_assert_msg(res == 0, "ip_equal(NULL, PTR): expected result 0, got %u.", res); |
107 | 107 | ||
108 | ip1.family = TOX_AF_INET; | 108 | ip1.family = TOX_AF_INET; |
@@ -165,7 +165,7 @@ static Suite *network_suite(void) | |||
165 | 165 | ||
166 | int main(void) | 166 | int main(void) |
167 | { | 167 | { |
168 | srand((unsigned int) time(NULL)); | 168 | srand((unsigned int) time(nullptr)); |
169 | 169 | ||
170 | Suite *network = network_suite(); | 170 | Suite *network = network_suite(); |
171 | SRunner *test_runner = srunner_create(network); | 171 | SRunner *test_runner = srunner_create(network); |
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 7db683de..bf764f67 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #ifndef _XOPEN_SOURCE | ||
1 | #define _XOPEN_SOURCE 600 | 2 | #define _XOPEN_SOURCE 600 |
3 | #endif | ||
2 | 4 | ||
3 | #ifdef HAVE_CONFIG_H | 5 | #ifdef HAVE_CONFIG_H |
4 | #include "config.h" | 6 | #include "config.h" |
@@ -37,7 +39,7 @@ static inline IP get_loopback() | |||
37 | } | 39 | } |
38 | static void do_onion(Onion *onion) | 40 | static void do_onion(Onion *onion) |
39 | { | 41 | { |
40 | networking_poll(onion->net, NULL); | 42 | networking_poll(onion->net, nullptr); |
41 | do_DHT(onion->dht); | 43 | do_DHT(onion->dht); |
42 | } | 44 | } |
43 | 45 | ||
@@ -159,9 +161,9 @@ static int handle_test_4(void *object, IP_Port source, const uint8_t *packet, ui | |||
159 | START_TEST(test_basic) | 161 | START_TEST(test_basic) |
160 | { | 162 | { |
161 | IP ip = get_loopback(); | 163 | IP ip = get_loopback(); |
162 | Onion *onion1 = new_onion(new_DHT(NULL, new_networking(NULL, ip, 34567), true)); | 164 | Onion *onion1 = new_onion(new_DHT(nullptr, new_networking(nullptr, ip, 34567), true)); |
163 | Onion *onion2 = new_onion(new_DHT(NULL, new_networking(NULL, ip, 34568), true)); | 165 | Onion *onion2 = new_onion(new_DHT(nullptr, new_networking(nullptr, ip, 34568), true)); |
164 | ck_assert_msg((onion1 != NULL) && (onion2 != NULL), "Onion failed initializing."); | 166 | ck_assert_msg((onion1 != nullptr) && (onion2 != nullptr), "Onion failed initializing."); |
165 | networking_registerhandler(onion2->net, 'I', &handle_test_1, onion2); | 167 | networking_registerhandler(onion2->net, 'I', &handle_test_1, onion2); |
166 | 168 | ||
167 | IP_Port on1 = {ip, net_port(onion1->net)}; | 169 | IP_Port on1 = {ip, net_port(onion1->net)}; |
@@ -203,7 +205,7 @@ START_TEST(test_basic) | |||
203 | Onion_Announce *onion1_a = new_onion_announce(onion1->dht); | 205 | Onion_Announce *onion1_a = new_onion_announce(onion1->dht); |
204 | Onion_Announce *onion2_a = new_onion_announce(onion2->dht); | 206 | Onion_Announce *onion2_a = new_onion_announce(onion2->dht); |
205 | networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE, &handle_test_3, onion1); | 207 | networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE, &handle_test_3, onion1); |
206 | ck_assert_msg((onion1_a != NULL) && (onion2_a != NULL), "Onion_Announce failed initializing."); | 208 | ck_assert_msg((onion1_a != nullptr) && (onion2_a != nullptr), "Onion_Announce failed initializing."); |
207 | uint8_t zeroes[64] = {0}; | 209 | uint8_t zeroes[64] = {0}; |
208 | random_bytes(sb_data, sizeof(sb_data)); | 210 | random_bytes(sb_data, sizeof(sb_data)); |
209 | uint64_t s; | 211 | uint64_t s; |
@@ -245,8 +247,8 @@ START_TEST(test_basic) | |||
245 | } | 247 | } |
246 | 248 | ||
247 | c_sleep(1000); | 249 | c_sleep(1000); |
248 | Onion *onion3 = new_onion(new_DHT(NULL, new_networking(NULL, ip, 34569), true)); | 250 | Onion *onion3 = new_onion(new_DHT(nullptr, new_networking(nullptr, ip, 34569), true)); |
249 | ck_assert_msg((onion3 != NULL), "Onion failed initializing."); | 251 | ck_assert_msg((onion3 != nullptr), "Onion failed initializing."); |
250 | 252 | ||
251 | random_nonce(nonce); | 253 | random_nonce(nonce); |
252 | ret = send_data_request(onion3->net, &path, nodes[3].ip_port, | 254 | ret = send_data_request(onion3->net, &path, nodes[3].ip_port, |
@@ -310,22 +312,22 @@ static Onions *new_onions(uint16_t port) | |||
310 | Onions *on = (Onions *)malloc(sizeof(Onions)); | 312 | Onions *on = (Onions *)malloc(sizeof(Onions)); |
311 | 313 | ||
312 | if (!on) { | 314 | if (!on) { |
313 | return NULL; | 315 | return nullptr; |
314 | } | 316 | } |
315 | 317 | ||
316 | Networking_Core *net = new_networking(NULL, ip, port); | 318 | Networking_Core *net = new_networking(nullptr, ip, port); |
317 | 319 | ||
318 | if (!net) { | 320 | if (!net) { |
319 | free(on); | 321 | free(on); |
320 | return NULL; | 322 | return nullptr; |
321 | } | 323 | } |
322 | 324 | ||
323 | DHT *dht = new_DHT(NULL, net, true); | 325 | DHT *dht = new_DHT(nullptr, net, true); |
324 | 326 | ||
325 | if (!dht) { | 327 | if (!dht) { |
326 | kill_networking(net); | 328 | kill_networking(net); |
327 | free(on); | 329 | free(on); |
328 | return NULL; | 330 | return nullptr; |
329 | } | 331 | } |
330 | 332 | ||
331 | on->onion = new_onion(dht); | 333 | on->onion = new_onion(dht); |
@@ -334,7 +336,7 @@ static Onions *new_onions(uint16_t port) | |||
334 | kill_DHT(dht); | 336 | kill_DHT(dht); |
335 | kill_networking(net); | 337 | kill_networking(net); |
336 | free(on); | 338 | free(on); |
337 | return NULL; | 339 | return nullptr; |
338 | } | 340 | } |
339 | 341 | ||
340 | on->onion_a = new_onion_announce(dht); | 342 | on->onion_a = new_onion_announce(dht); |
@@ -344,11 +346,11 @@ static Onions *new_onions(uint16_t port) | |||
344 | kill_DHT(dht); | 346 | kill_DHT(dht); |
345 | kill_networking(net); | 347 | kill_networking(net); |
346 | free(on); | 348 | free(on); |
347 | return NULL; | 349 | return nullptr; |
348 | } | 350 | } |
349 | 351 | ||
350 | TCP_Proxy_Info inf = {{{0}}}; | 352 | TCP_Proxy_Info inf = {{{0}}}; |
351 | on->onion_c = new_onion_client(new_net_crypto(NULL, dht, &inf)); | 353 | on->onion_c = new_onion_client(new_net_crypto(nullptr, dht, &inf)); |
352 | 354 | ||
353 | if (!on->onion_c) { | 355 | if (!on->onion_c) { |
354 | kill_onion_announce(on->onion_a); | 356 | kill_onion_announce(on->onion_a); |
@@ -356,7 +358,7 @@ static Onions *new_onions(uint16_t port) | |||
356 | kill_DHT(dht); | 358 | kill_DHT(dht); |
357 | kill_networking(net); | 359 | kill_networking(net); |
358 | free(on); | 360 | free(on); |
359 | return NULL; | 361 | return nullptr; |
360 | } | 362 | } |
361 | 363 | ||
362 | return on; | 364 | return on; |
@@ -364,7 +366,7 @@ static Onions *new_onions(uint16_t port) | |||
364 | 366 | ||
365 | static void do_onions(Onions *on) | 367 | static void do_onions(Onions *on) |
366 | { | 368 | { |
367 | networking_poll(on->onion->net, NULL); | 369 | networking_poll(on->onion->net, nullptr); |
368 | do_DHT(on->onion->dht); | 370 | do_DHT(on->onion->dht); |
369 | do_onion_client(on->onion_c); | 371 | do_onion_client(on->onion_c); |
370 | } | 372 | } |
@@ -447,7 +449,7 @@ START_TEST(test_announce) | |||
447 | 449 | ||
448 | for (i = 0; i < NUM_ONIONS; ++i) { | 450 | for (i = 0; i < NUM_ONIONS; ++i) { |
449 | onions[i] = new_onions(i + 34655); | 451 | onions[i] = new_onions(i + 34655); |
450 | ck_assert_msg(onions[i] != 0, "Failed to create onions. %u"); | 452 | ck_assert_msg(onions[i] != nullptr, "Failed to create onions. %u"); |
451 | } | 453 | } |
452 | 454 | ||
453 | IP ip = get_loopback(); | 455 | IP ip = get_loopback(); |
@@ -536,7 +538,7 @@ static Suite *onion_suite(void) | |||
536 | 538 | ||
537 | int main(int argc, char *argv[]) | 539 | int main(int argc, char *argv[]) |
538 | { | 540 | { |
539 | srand((unsigned int) time(NULL)); | 541 | srand((unsigned int) time(nullptr)); |
540 | 542 | ||
541 | Suite *onion = onion_suite(); | 543 | Suite *onion = onion_suite(); |
542 | SRunner *test_runner = srunner_create(onion); | 544 | SRunner *test_runner = srunner_create(onion); |
diff --git a/auto_tests/resource_leak_test.c b/auto_tests/resource_leak_test.c index 5b25bc77..65a6dbb8 100644 --- a/auto_tests/resource_leak_test.c +++ b/auto_tests/resource_leak_test.c | |||
@@ -27,8 +27,8 @@ int main(void) | |||
27 | 27 | ||
28 | // Warm-up. | 28 | // Warm-up. |
29 | for (i = 0; i < 10; i++) { | 29 | for (i = 0; i < 10; i++) { |
30 | Tox *tox = tox_new(0, 0); | 30 | Tox *tox = tox_new(nullptr, nullptr); |
31 | tox_iterate(tox, NULL); | 31 | tox_iterate(tox, nullptr); |
32 | tox_kill(tox); | 32 | tox_kill(tox); |
33 | } | 33 | } |
34 | 34 | ||
@@ -39,8 +39,8 @@ int main(void) | |||
39 | printf("Creating/deleting %d tox instances\n", ITERATIONS); | 39 | printf("Creating/deleting %d tox instances\n", ITERATIONS); |
40 | 40 | ||
41 | for (i = 0; i < ITERATIONS; i++) { | 41 | for (i = 0; i < ITERATIONS; i++) { |
42 | Tox *tox = tox_new(0, 0); | 42 | Tox *tox = tox_new(nullptr, nullptr); |
43 | tox_iterate(tox, NULL); | 43 | tox_iterate(tox, nullptr); |
44 | tox_kill(tox); | 44 | tox_kill(tox); |
45 | #if HAVE_SBRK | 45 | #if HAVE_SBRK |
46 | char *next_hwm = (char *)sbrk(0); | 46 | char *next_hwm = (char *)sbrk(0); |
diff --git a/auto_tests/save_friend_test.c b/auto_tests/save_friend_test.c index 061425bd..a7a62c87 100644 --- a/auto_tests/save_friend_test.c +++ b/auto_tests/save_friend_test.c | |||
@@ -1,7 +1,9 @@ | |||
1 | /* Auto Tests: Save and load friends. | 1 | /* Auto Tests: Save and load friends. |
2 | */ | 2 | */ |
3 | 3 | ||
4 | #ifndef _XOPEN_SOURCE | ||
4 | #define _XOPEN_SOURCE 600 | 5 | #define _XOPEN_SOURCE 600 |
6 | #endif | ||
5 | 7 | ||
6 | #include "helpers.h" | 8 | #include "helpers.h" |
7 | #include "../toxcore/ccompat.h" | 9 | #include "../toxcore/ccompat.h" |
@@ -28,7 +30,7 @@ static void set_random(Tox *m, bool (*setter)(Tox *, const uint8_t *, size_t, TO | |||
28 | text[i] = rand(); | 30 | text[i] = rand(); |
29 | } | 31 | } |
30 | 32 | ||
31 | setter(m, text, SIZEOF_VLA(text), 0); | 33 | setter(m, text, SIZEOF_VLA(text), nullptr); |
32 | } | 34 | } |
33 | 35 | ||
34 | void namechange_callback(Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length, void *user_data) | 36 | void namechange_callback(Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length, void *user_data) |
@@ -47,16 +49,16 @@ void statuschange_callback(Tox *tox, uint32_t friend_number, const uint8_t *mess | |||
47 | 49 | ||
48 | int main(int argc, char *argv[]) | 50 | int main(int argc, char *argv[]) |
49 | { | 51 | { |
50 | Tox *tox1 = tox_new_log(0, 0, 0); | 52 | Tox *tox1 = tox_new_log(nullptr, nullptr, nullptr); |
51 | Tox *tox2 = tox_new_log(0, 0, 0); | 53 | Tox *tox2 = tox_new_log(nullptr, nullptr, nullptr); |
52 | 54 | ||
53 | struct test_data to_compare = { { 0 } }; | 55 | struct test_data to_compare = { { 0 } }; |
54 | 56 | ||
55 | uint8_t public_key[TOX_PUBLIC_KEY_SIZE]; | 57 | uint8_t public_key[TOX_PUBLIC_KEY_SIZE]; |
56 | tox_self_get_public_key(tox1, public_key); | 58 | tox_self_get_public_key(tox1, public_key); |
57 | tox_friend_add_norequest(tox2, public_key, NULL); | 59 | tox_friend_add_norequest(tox2, public_key, nullptr); |
58 | tox_self_get_public_key(tox2, public_key); | 60 | tox_self_get_public_key(tox2, public_key); |
59 | tox_friend_add_norequest(tox1, public_key, NULL); | 61 | tox_friend_add_norequest(tox1, public_key, nullptr); |
60 | 62 | ||
61 | uint8_t reference_name[TOX_MAX_NAME_LENGTH] = { 0 }; | 63 | uint8_t reference_name[TOX_MAX_NAME_LENGTH] = { 0 }; |
62 | uint8_t reference_status[TOX_MAX_STATUS_MESSAGE_LENGTH] = { 0 }; | 64 | uint8_t reference_status[TOX_MAX_STATUS_MESSAGE_LENGTH] = { 0 }; |
@@ -75,13 +77,13 @@ int main(int argc, char *argv[]) | |||
75 | while (true) { | 77 | while (true) { |
76 | if (tox_self_get_connection_status(tox1) && | 78 | if (tox_self_get_connection_status(tox1) && |
77 | tox_self_get_connection_status(tox2) && | 79 | tox_self_get_connection_status(tox2) && |
78 | tox_friend_get_connection_status(tox1, 0, 0) == TOX_CONNECTION_UDP) { | 80 | tox_friend_get_connection_status(tox1, 0, nullptr) == TOX_CONNECTION_UDP) { |
79 | printf("Connected.\n"); | 81 | printf("Connected.\n"); |
80 | break; | 82 | break; |
81 | } | 83 | } |
82 | 84 | ||
83 | tox_iterate(tox1, &to_compare); | 85 | tox_iterate(tox1, &to_compare); |
84 | tox_iterate(tox2, NULL); | 86 | tox_iterate(tox2, nullptr); |
85 | 87 | ||
86 | c_sleep(tox_iteration_interval(tox1)); | 88 | c_sleep(tox_iteration_interval(tox1)); |
87 | } | 89 | } |
@@ -93,7 +95,7 @@ int main(int argc, char *argv[]) | |||
93 | } | 95 | } |
94 | 96 | ||
95 | tox_iterate(tox1, &to_compare); | 97 | tox_iterate(tox1, &to_compare); |
96 | tox_iterate(tox2, NULL); | 98 | tox_iterate(tox2, nullptr); |
97 | 99 | ||
98 | c_sleep(tox_iteration_interval(tox1)); | 100 | c_sleep(tox_iteration_interval(tox1)); |
99 | } | 101 | } |
@@ -102,14 +104,14 @@ int main(int argc, char *argv[]) | |||
102 | VLA(uint8_t, savedata, save_size); | 104 | VLA(uint8_t, savedata, save_size); |
103 | tox_get_savedata(tox1, savedata); | 105 | tox_get_savedata(tox1, savedata); |
104 | 106 | ||
105 | struct Tox_Options *options = tox_options_new(NULL); | 107 | struct Tox_Options *options = tox_options_new(nullptr); |
106 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); | 108 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); |
107 | tox_options_set_savedata_data(options, savedata, save_size); | 109 | tox_options_set_savedata_data(options, savedata, save_size); |
108 | 110 | ||
109 | Tox *tox_to_compare = tox_new(options, 0); | 111 | Tox *tox_to_compare = tox_new(options, nullptr); |
110 | 112 | ||
111 | tox_friend_get_name(tox_to_compare, 0, to_compare.name, 0); | 113 | tox_friend_get_name(tox_to_compare, 0, to_compare.name, nullptr); |
112 | tox_friend_get_status_message(tox_to_compare, 0, to_compare.status_message, 0); | 114 | tox_friend_get_status_message(tox_to_compare, 0, to_compare.status_message, nullptr); |
113 | 115 | ||
114 | assert(memcmp(reference_name, to_compare.name, TOX_MAX_NAME_LENGTH) == 0); | 116 | assert(memcmp(reference_name, to_compare.name, TOX_MAX_NAME_LENGTH) == 0); |
115 | assert(memcmp(reference_status, to_compare.status_message, TOX_MAX_STATUS_MESSAGE_LENGTH) == 0); | 117 | assert(memcmp(reference_status, to_compare.status_message, TOX_MAX_STATUS_MESSAGE_LENGTH) == 0); |
diff --git a/auto_tests/self_conference_title_change_test.c b/auto_tests/self_conference_title_change_test.c index c780f320..a8ba7aab 100644 --- a/auto_tests/self_conference_title_change_test.c +++ b/auto_tests/self_conference_title_change_test.c | |||
@@ -21,7 +21,9 @@ | |||
21 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. |
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | #define _XOPEN_SOURCE 500 | 24 | #ifndef _XOPEN_SOURCE |
25 | #define _XOPEN_SOURCE 600 | ||
26 | #endif | ||
25 | 27 | ||
26 | #include <stdio.h> | 28 | #include <stdio.h> |
27 | #include <stdlib.h> | 29 | #include <stdlib.h> |
@@ -38,7 +40,7 @@ static const char *newtitle = "kitten over darknet"; | |||
38 | static void cbtitlechange(Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *title, | 40 | static void cbtitlechange(Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *title, |
39 | size_t length, void *user_data) | 41 | size_t length, void *user_data) |
40 | { | 42 | { |
41 | if (!memcmp(title, newtitle, tox_conference_get_title_size(tox, conference_number, NULL))) { | 43 | if (!memcmp(title, newtitle, tox_conference_get_title_size(tox, conference_number, nullptr))) { |
42 | printf("success: title was changed and updated in the conference"); | 44 | printf("success: title was changed and updated in the conference"); |
43 | exit(0); | 45 | exit(0); |
44 | } | 46 | } |
@@ -47,12 +49,12 @@ static void cbtitlechange(Tox *tox, uint32_t conference_number, uint32_t peer_nu | |||
47 | int main(void) | 49 | int main(void) |
48 | { | 50 | { |
49 | uint32_t conference_number; | 51 | uint32_t conference_number; |
50 | struct Tox_Options *to = tox_options_new(NULL); | 52 | struct Tox_Options *to = tox_options_new(nullptr); |
51 | Tox *t; | 53 | Tox *t; |
52 | TOX_ERR_CONFERENCE_NEW conference_err; | 54 | TOX_ERR_CONFERENCE_NEW conference_err; |
53 | TOX_ERR_CONFERENCE_TITLE title_err; | 55 | TOX_ERR_CONFERENCE_TITLE title_err; |
54 | 56 | ||
55 | t = tox_new(to, NULL); | 57 | t = tox_new(to, nullptr); |
56 | tox_options_free(to); | 58 | tox_options_free(to); |
57 | 59 | ||
58 | tox_callback_conference_title(t, &cbtitlechange); | 60 | tox_callback_conference_title(t, &cbtitlechange); |
@@ -63,7 +65,7 @@ int main(void) | |||
63 | return 2; | 65 | return 2; |
64 | } | 66 | } |
65 | 67 | ||
66 | tox_iterate(t, NULL); | 68 | tox_iterate(t, nullptr); |
67 | c_sleep(tox_iteration_interval(t)); | 69 | c_sleep(tox_iteration_interval(t)); |
68 | 70 | ||
69 | if (!tox_conference_set_title(t, conference_number, (const uint8_t *)newtitle, strlen(newtitle), &title_err)) { | 71 | if (!tox_conference_set_title(t, conference_number, (const uint8_t *)newtitle, strlen(newtitle), &title_err)) { |
@@ -72,9 +74,9 @@ int main(void) | |||
72 | return 3; | 74 | return 3; |
73 | } | 75 | } |
74 | 76 | ||
75 | tox_iterate(t, NULL); | 77 | tox_iterate(t, nullptr); |
76 | c_sleep(tox_iteration_interval(t)); | 78 | c_sleep(tox_iteration_interval(t)); |
77 | tox_iterate(t, NULL); | 79 | tox_iterate(t, nullptr); |
78 | 80 | ||
79 | fprintf(stderr, "error: title was not changed in callback. exiting.\n"); | 81 | fprintf(stderr, "error: title was not changed in callback. exiting.\n"); |
80 | 82 | ||
diff --git a/auto_tests/selfname_change_conference_test.c b/auto_tests/selfname_change_conference_test.c index 3d2436b5..cd2c2b22 100644 --- a/auto_tests/selfname_change_conference_test.c +++ b/auto_tests/selfname_change_conference_test.c | |||
@@ -21,7 +21,9 @@ | |||
21 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. |
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | #define _XOPEN_SOURCE 500 | 24 | #ifndef _XOPEN_SOURCE |
25 | #define _XOPEN_SOURCE 600 | ||
26 | #endif | ||
25 | 27 | ||
26 | #include <stdio.h> | 28 | #include <stdio.h> |
27 | #include <stdlib.h> | 29 | #include <stdlib.h> |
@@ -45,11 +47,11 @@ static void cbconfmembers(Tox *tox, uint32_t conference_number, uint32_t peer_nu | |||
45 | return; | 47 | return; |
46 | } | 48 | } |
47 | 49 | ||
48 | if (!tox_conference_peer_get_name(tox, conference_number, peer_number, new_peer_name, NULL)) { | 50 | if (!tox_conference_peer_get_name(tox, conference_number, peer_number, new_peer_name, nullptr)) { |
49 | return; | 51 | return; |
50 | } | 52 | } |
51 | 53 | ||
52 | if (!memcmp(newname, new_peer_name, tox_conference_peer_get_name_size(tox, conference_number, peer_number, NULL))) { | 54 | if (!memcmp(newname, new_peer_name, tox_conference_peer_get_name_size(tox, conference_number, peer_number, nullptr))) { |
53 | printf("success: own name was changed and updated in the conference"); | 55 | printf("success: own name was changed and updated in the conference"); |
54 | exit(0); | 56 | exit(0); |
55 | } | 57 | } |
@@ -57,12 +59,12 @@ static void cbconfmembers(Tox *tox, uint32_t conference_number, uint32_t peer_nu | |||
57 | 59 | ||
58 | int main(void) | 60 | int main(void) |
59 | { | 61 | { |
60 | struct Tox_Options *to = tox_options_new(NULL); | 62 | struct Tox_Options *to = tox_options_new(nullptr); |
61 | Tox *t; | 63 | Tox *t; |
62 | TOX_ERR_CONFERENCE_NEW conference_err; | 64 | TOX_ERR_CONFERENCE_NEW conference_err; |
63 | TOX_ERR_SET_INFO name_err; | 65 | TOX_ERR_SET_INFO name_err; |
64 | 66 | ||
65 | t = tox_new(to, NULL); | 67 | t = tox_new(to, nullptr); |
66 | tox_options_free(to); | 68 | tox_options_free(to); |
67 | 69 | ||
68 | tox_callback_conference_namelist_change(t, cbconfmembers); | 70 | tox_callback_conference_namelist_change(t, cbconfmembers); |
@@ -73,7 +75,7 @@ int main(void) | |||
73 | return 2; | 75 | return 2; |
74 | } | 76 | } |
75 | 77 | ||
76 | tox_iterate(t, NULL); | 78 | tox_iterate(t, nullptr); |
77 | c_sleep(tox_iteration_interval(t)); | 79 | c_sleep(tox_iteration_interval(t)); |
78 | 80 | ||
79 | if (!tox_self_set_name(t, (const uint8_t *)newname, strlen(newname), &name_err)) { | 81 | if (!tox_self_set_name(t, (const uint8_t *)newname, strlen(newname), &name_err)) { |
@@ -82,9 +84,9 @@ int main(void) | |||
82 | return 3; | 84 | return 3; |
83 | } | 85 | } |
84 | 86 | ||
85 | tox_iterate(t, NULL); | 87 | tox_iterate(t, nullptr); |
86 | c_sleep(tox_iteration_interval(t)); | 88 | c_sleep(tox_iteration_interval(t)); |
87 | tox_iterate(t, NULL); | 89 | tox_iterate(t, nullptr); |
88 | 90 | ||
89 | fprintf(stderr, "error: name was not changed in callback. exiting.\n"); | 91 | fprintf(stderr, "error: name was not changed in callback. exiting.\n"); |
90 | 92 | ||
diff --git a/auto_tests/simple_conference_test.c b/auto_tests/simple_conference_test.c index b3a8c024..b6c19d13 100644 --- a/auto_tests/simple_conference_test.c +++ b/auto_tests/simple_conference_test.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #ifndef _XOPEN_SOURCE | ||
1 | #define _XOPEN_SOURCE 600 | 2 | #define _XOPEN_SOURCE 600 |
3 | #endif | ||
2 | 4 | ||
3 | #include "../toxcore/tox.h" | 5 | #include "../toxcore/tox.h" |
4 | 6 | ||
@@ -106,20 +108,20 @@ int main() | |||
106 | State state3 = {3}; | 108 | State state3 = {3}; |
107 | 109 | ||
108 | // Create toxes. | 110 | // Create toxes. |
109 | Tox *tox1 = tox_new_log(NULL, NULL, &state1.id); | 111 | Tox *tox1 = tox_new_log(nullptr, nullptr, &state1.id); |
110 | Tox *tox2 = tox_new_log(NULL, NULL, &state2.id); | 112 | Tox *tox2 = tox_new_log(nullptr, nullptr, &state2.id); |
111 | Tox *tox3 = tox_new_log(NULL, NULL, &state3.id); | 113 | Tox *tox3 = tox_new_log(nullptr, nullptr, &state3.id); |
112 | 114 | ||
113 | // tox1 <-> tox2, tox2 <-> tox3 | 115 | // tox1 <-> tox2, tox2 <-> tox3 |
114 | uint8_t key[TOX_PUBLIC_KEY_SIZE]; | 116 | uint8_t key[TOX_PUBLIC_KEY_SIZE]; |
115 | tox_self_get_public_key(tox2, key); | 117 | tox_self_get_public_key(tox2, key); |
116 | tox_friend_add_norequest(tox1, key, NULL); // tox1 -> tox2 | 118 | tox_friend_add_norequest(tox1, key, nullptr); // tox1 -> tox2 |
117 | tox_self_get_public_key(tox1, key); | 119 | tox_self_get_public_key(tox1, key); |
118 | tox_friend_add_norequest(tox2, key, NULL); // tox2 -> tox1 | 120 | tox_friend_add_norequest(tox2, key, nullptr); // tox2 -> tox1 |
119 | tox_self_get_public_key(tox3, key); | 121 | tox_self_get_public_key(tox3, key); |
120 | tox_friend_add_norequest(tox2, key, NULL); // tox2 -> tox3 | 122 | tox_friend_add_norequest(tox2, key, nullptr); // tox2 -> tox3 |
121 | tox_self_get_public_key(tox2, key); | 123 | tox_self_get_public_key(tox2, key); |
122 | tox_friend_add_norequest(tox3, key, NULL); // tox3 -> tox2 | 124 | tox_friend_add_norequest(tox3, key, nullptr); // tox3 -> tox2 |
123 | 125 | ||
124 | // Connection callbacks. | 126 | // Connection callbacks. |
125 | tox_callback_self_connection_status(tox1, handle_self_connection_status); | 127 | tox_callback_self_connection_status(tox1, handle_self_connection_status); |
diff --git a/auto_tests/skeleton_test.c b/auto_tests/skeleton_test.c index 48f95093..d52faba4 100644 --- a/auto_tests/skeleton_test.c +++ b/auto_tests/skeleton_test.c | |||
@@ -31,7 +31,7 @@ static Suite *creativesuitenamegoeshere_suite(void) | |||
31 | 31 | ||
32 | int main(int argc, char *argv[]) | 32 | int main(int argc, char *argv[]) |
33 | { | 33 | { |
34 | srand((unsigned int) time(NULL)); | 34 | srand((unsigned int) time(nullptr)); |
35 | 35 | ||
36 | Suite *creativesuitenamegoeshere = creativesuitenamegoeshere_suite(); | 36 | Suite *creativesuitenamegoeshere = creativesuitenamegoeshere_suite(); |
37 | SRunner *test_runner = srunner_create(creativesuitenamegoeshere); | 37 | SRunner *test_runner = srunner_create(creativesuitenamegoeshere); |
diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c index dce8fc2b..81e6244a 100644 --- a/auto_tests/tox_many_tcp_test.c +++ b/auto_tests/tox_many_tcp_test.c | |||
@@ -1,7 +1,9 @@ | |||
1 | /* Auto Tests: Many TCP. | 1 | /* Auto Tests: Many TCP. |
2 | */ | 2 | */ |
3 | 3 | ||
4 | #ifndef _XOPEN_SOURCE | ||
4 | #define _XOPEN_SOURCE 600 | 5 | #define _XOPEN_SOURCE 600 |
6 | #endif | ||
5 | 7 | ||
6 | #ifdef HAVE_CONFIG_H | 8 | #ifdef HAVE_CONFIG_H |
7 | #include "config.h" | 9 | #include "config.h" |
@@ -33,7 +35,7 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
33 | } | 35 | } |
34 | 36 | ||
35 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { | 37 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { |
36 | tox_friend_add_norequest(m, public_key, 0); | 38 | tox_friend_add_norequest(m, public_key, nullptr); |
37 | } | 39 | } |
38 | } | 40 | } |
39 | 41 | ||
@@ -43,32 +45,32 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
43 | 45 | ||
44 | START_TEST(test_many_clients_tcp) | 46 | START_TEST(test_many_clients_tcp) |
45 | { | 47 | { |
46 | long long unsigned int cur_time = time(NULL); | 48 | long long unsigned int cur_time = time(nullptr); |
47 | Tox *toxes[NUM_TOXES_TCP]; | 49 | Tox *toxes[NUM_TOXES_TCP]; |
48 | uint32_t index[NUM_TOXES_TCP]; | 50 | uint32_t index[NUM_TOXES_TCP]; |
49 | uint32_t i, j; | 51 | uint32_t i, j; |
50 | uint32_t to_comp = 974536; | 52 | uint32_t to_comp = 974536; |
51 | 53 | ||
52 | for (i = 0; i < NUM_TOXES_TCP; ++i) { | 54 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
53 | struct Tox_Options *opts = tox_options_new(NULL); | 55 | struct Tox_Options *opts = tox_options_new(nullptr); |
54 | 56 | ||
55 | if (i == 0) { | 57 | if (i == 0) { |
56 | tox_options_set_tcp_port(opts, TCP_RELAY_PORT); | 58 | tox_options_set_tcp_port(opts, TCP_RELAY_PORT); |
57 | } else { | 59 | } else { |
58 | tox_options_set_udp_enabled(opts, 0); | 60 | tox_options_set_udp_enabled(opts, false); |
59 | } | 61 | } |
60 | 62 | ||
61 | index[i] = i + 1; | 63 | index[i] = i + 1; |
62 | toxes[i] = tox_new_log(opts, 0, &index[i]); | 64 | toxes[i] = tox_new_log(opts, nullptr, &index[i]); |
63 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 65 | ck_assert_msg(toxes[i] != nullptr, "Failed to create tox instances %u", i); |
64 | tox_callback_friend_request(toxes[i], accept_friend_request); | 66 | tox_callback_friend_request(toxes[i], accept_friend_request); |
65 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 67 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
66 | tox_self_get_dht_id(toxes[0], dpk); | 68 | tox_self_get_dht_id(toxes[0], dpk); |
67 | TOX_ERR_BOOTSTRAP error = TOX_ERR_BOOTSTRAP_OK; | 69 | TOX_ERR_BOOTSTRAP error = TOX_ERR_BOOTSTRAP_OK; |
68 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT, dpk, &error), "add relay error, %i, %i", i, | 70 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT, dpk, &error), "add relay error, %i, %i", i, |
69 | error); | 71 | error); |
70 | uint16_t first_port = tox_self_get_udp_port(toxes[0], NULL); | 72 | uint16_t first_port = tox_self_get_udp_port(toxes[0], nullptr); |
71 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, first_port, dpk, 0), "Bootstrap error"); | 73 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, first_port, dpk, nullptr), "Bootstrap error"); |
72 | 74 | ||
73 | tox_options_free(opts); | 75 | tox_options_free(opts); |
74 | } | 76 | } |
@@ -119,7 +121,7 @@ loop_top: | |||
119 | 121 | ||
120 | for (i = 0; i < NUM_TOXES_TCP; ++i) { | 122 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
121 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) { | 123 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) { |
122 | if (tox_friend_get_connection_status(toxes[i], j, 0) == TOX_CONNECTION_TCP) { | 124 | if (tox_friend_get_connection_status(toxes[i], j, nullptr) == TOX_CONNECTION_TCP) { |
123 | ++counter; | 125 | ++counter; |
124 | } | 126 | } |
125 | } | 127 | } |
@@ -140,7 +142,7 @@ loop_top: | |||
140 | tox_kill(toxes[i]); | 142 | tox_kill(toxes[i]); |
141 | } | 143 | } |
142 | 144 | ||
143 | printf("test_many_clients_tcp succeeded, took %llu seconds\n", time(NULL) - cur_time); | 145 | printf("test_many_clients_tcp succeeded, took %llu seconds\n", time(nullptr) - cur_time); |
144 | } | 146 | } |
145 | END_TEST | 147 | END_TEST |
146 | 148 | ||
@@ -148,14 +150,14 @@ END_TEST | |||
148 | 150 | ||
149 | START_TEST(test_many_clients_tcp_b) | 151 | START_TEST(test_many_clients_tcp_b) |
150 | { | 152 | { |
151 | long long unsigned int cur_time = time(NULL); | 153 | long long unsigned int cur_time = time(nullptr); |
152 | Tox *toxes[NUM_TOXES_TCP]; | 154 | Tox *toxes[NUM_TOXES_TCP]; |
153 | uint32_t index[NUM_TOXES_TCP]; | 155 | uint32_t index[NUM_TOXES_TCP]; |
154 | uint32_t i, j; | 156 | uint32_t i, j; |
155 | uint32_t to_comp = 974536; | 157 | uint32_t to_comp = 974536; |
156 | 158 | ||
157 | for (i = 0; i < NUM_TOXES_TCP; ++i) { | 159 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
158 | struct Tox_Options *opts = tox_options_new(NULL); | 160 | struct Tox_Options *opts = tox_options_new(nullptr); |
159 | 161 | ||
160 | if (i < NUM_TCP_RELAYS) { | 162 | if (i < NUM_TCP_RELAYS) { |
161 | tox_options_set_tcp_port(opts, TCP_RELAY_PORT + i); | 163 | tox_options_set_tcp_port(opts, TCP_RELAY_PORT + i); |
@@ -164,16 +166,16 @@ START_TEST(test_many_clients_tcp_b) | |||
164 | } | 166 | } |
165 | 167 | ||
166 | index[i] = i + 1; | 168 | index[i] = i + 1; |
167 | toxes[i] = tox_new_log(opts, 0, &index[i]); | 169 | toxes[i] = tox_new_log(opts, nullptr, &index[i]); |
168 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 170 | ck_assert_msg(toxes[i] != nullptr, "Failed to create tox instances %u", i); |
169 | tox_callback_friend_request(toxes[i], accept_friend_request); | 171 | tox_callback_friend_request(toxes[i], accept_friend_request); |
170 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 172 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
171 | tox_self_get_dht_id(toxes[(i % NUM_TCP_RELAYS)], dpk); | 173 | tox_self_get_dht_id(toxes[(i % NUM_TCP_RELAYS)], dpk); |
172 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT + (i % NUM_TCP_RELAYS), dpk, 0), | 174 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT + (i % NUM_TCP_RELAYS), dpk, nullptr), |
173 | "add relay error"); | 175 | "add relay error"); |
174 | tox_self_get_dht_id(toxes[0], dpk); | 176 | tox_self_get_dht_id(toxes[0], dpk); |
175 | uint16_t first_port = tox_self_get_udp_port(toxes[0], NULL); | 177 | uint16_t first_port = tox_self_get_udp_port(toxes[0], nullptr); |
176 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, first_port, dpk, 0), "Bootstrap error"); | 178 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, first_port, dpk, nullptr), "Bootstrap error"); |
177 | 179 | ||
178 | tox_options_free(opts); | 180 | tox_options_free(opts); |
179 | } | 181 | } |
@@ -226,7 +228,7 @@ loop_top: | |||
226 | 228 | ||
227 | for (i = 0; i < NUM_TOXES_TCP; ++i) { | 229 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
228 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) { | 230 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) { |
229 | if (tox_friend_get_connection_status(toxes[i], j, 0) == TOX_CONNECTION_TCP) { | 231 | if (tox_friend_get_connection_status(toxes[i], j, nullptr) == TOX_CONNECTION_TCP) { |
230 | ++counter; | 232 | ++counter; |
231 | } | 233 | } |
232 | } | 234 | } |
@@ -252,7 +254,7 @@ loop_top: | |||
252 | tox_kill(toxes[i]); | 254 | tox_kill(toxes[i]); |
253 | } | 255 | } |
254 | 256 | ||
255 | printf("test_many_clients_tcp_b succeeded, took %llu seconds\n", time(NULL) - cur_time); | 257 | printf("test_many_clients_tcp_b succeeded, took %llu seconds\n", time(nullptr) - cur_time); |
256 | } | 258 | } |
257 | END_TEST | 259 | END_TEST |
258 | 260 | ||
@@ -278,7 +280,7 @@ static Suite *tox_suite(void) | |||
278 | 280 | ||
279 | int main(int argc, char *argv[]) | 281 | int main(int argc, char *argv[]) |
280 | { | 282 | { |
281 | srand((unsigned int) time(NULL)); | 283 | srand((unsigned int) time(nullptr)); |
282 | 284 | ||
283 | Suite *tox = tox_suite(); | 285 | Suite *tox = tox_suite(); |
284 | SRunner *test_runner = srunner_create(tox); | 286 | SRunner *test_runner = srunner_create(tox); |
diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c index 7ab0facc..3d3aad6d 100644 --- a/auto_tests/tox_many_test.c +++ b/auto_tests/tox_many_test.c | |||
@@ -1,7 +1,9 @@ | |||
1 | /* Auto Tests: Many clients. | 1 | /* Auto Tests: Many clients. |
2 | */ | 2 | */ |
3 | 3 | ||
4 | #ifndef _XOPEN_SOURCE | ||
4 | #define _XOPEN_SOURCE 600 | 5 | #define _XOPEN_SOURCE 600 |
6 | #endif | ||
5 | 7 | ||
6 | #ifdef HAVE_CONFIG_H | 8 | #ifdef HAVE_CONFIG_H |
7 | #include "config.h" | 9 | #include "config.h" |
@@ -25,7 +27,7 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
25 | } | 27 | } |
26 | 28 | ||
27 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { | 29 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { |
28 | tox_friend_add_norequest(m, public_key, 0); | 30 | tox_friend_add_norequest(m, public_key, nullptr); |
29 | } | 31 | } |
30 | } | 32 | } |
31 | 33 | ||
@@ -35,7 +37,7 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
35 | 37 | ||
36 | START_TEST(test_many_clients) | 38 | START_TEST(test_many_clients) |
37 | { | 39 | { |
38 | long long unsigned int cur_time = time(NULL); | 40 | long long unsigned int cur_time = time(nullptr); |
39 | Tox *toxes[NUM_TOXES]; | 41 | Tox *toxes[NUM_TOXES]; |
40 | uint32_t index[NUM_TOXES]; | 42 | uint32_t index[NUM_TOXES]; |
41 | uint32_t i, j; | 43 | uint32_t i, j; |
@@ -43,8 +45,8 @@ START_TEST(test_many_clients) | |||
43 | 45 | ||
44 | for (i = 0; i < NUM_TOXES; ++i) { | 46 | for (i = 0; i < NUM_TOXES; ++i) { |
45 | index[i] = i + 1; | 47 | index[i] = i + 1; |
46 | toxes[i] = tox_new_log(0, 0, &index[i]); | 48 | toxes[i] = tox_new_log(nullptr, nullptr, &index[i]); |
47 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 49 | ck_assert_msg(toxes[i] != nullptr, "Failed to create tox instances %u", i); |
48 | tox_callback_friend_request(toxes[i], accept_friend_request); | 50 | tox_callback_friend_request(toxes[i], accept_friend_request); |
49 | } | 51 | } |
50 | 52 | ||
@@ -107,7 +109,7 @@ loop_top: | |||
107 | 109 | ||
108 | for (i = 0; i < NUM_TOXES; ++i) { | 110 | for (i = 0; i < NUM_TOXES; ++i) { |
109 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) { | 111 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) { |
110 | if (tox_friend_get_connection_status(toxes[i], j, 0) == TOX_CONNECTION_UDP) { | 112 | if (tox_friend_get_connection_status(toxes[i], j, nullptr) == TOX_CONNECTION_UDP) { |
111 | ++counter; | 113 | ++counter; |
112 | } | 114 | } |
113 | } | 115 | } |
@@ -133,7 +135,7 @@ loop_top: | |||
133 | tox_kill(toxes[i]); | 135 | tox_kill(toxes[i]); |
134 | } | 136 | } |
135 | 137 | ||
136 | printf("test_many_clients succeeded, took %llu seconds\n", time(NULL) - cur_time); | 138 | printf("test_many_clients succeeded, took %llu seconds\n", time(nullptr) - cur_time); |
137 | } | 139 | } |
138 | END_TEST | 140 | END_TEST |
139 | 141 | ||
@@ -154,7 +156,7 @@ static Suite *tox_suite(void) | |||
154 | 156 | ||
155 | int main(int argc, char *argv[]) | 157 | int main(int argc, char *argv[]) |
156 | { | 158 | { |
157 | srand((unsigned int) time(NULL)); | 159 | srand((unsigned int) time(nullptr)); |
158 | 160 | ||
159 | Suite *tox = tox_suite(); | 161 | Suite *tox = tox_suite(); |
160 | SRunner *test_runner = srunner_create(tox); | 162 | SRunner *test_runner = srunner_create(tox); |
diff --git a/auto_tests/tox_one_test.c b/auto_tests/tox_one_test.c index 7a429ac8..2f70fae6 100644 --- a/auto_tests/tox_one_test.c +++ b/auto_tests/tox_one_test.c | |||
@@ -38,9 +38,9 @@ START_TEST(test_one) | |||
38 | uint8_t status_message2[TOX_MAX_STATUS_MESSAGE_LENGTH]; | 38 | uint8_t status_message2[TOX_MAX_STATUS_MESSAGE_LENGTH]; |
39 | 39 | ||
40 | uint32_t index[] = { 1, 2 }; | 40 | uint32_t index[] = { 1, 2 }; |
41 | Tox *tox1 = tox_new_log(0, 0, &index[0]); | 41 | Tox *tox1 = tox_new_log(nullptr, nullptr, &index[0]); |
42 | set_random_name_and_status_message(tox1, name, status_message); | 42 | set_random_name_and_status_message(tox1, name, status_message); |
43 | Tox *tox2 = tox_new_log(0, 0, &index[1]); | 43 | Tox *tox2 = tox_new_log(nullptr, nullptr, &index[1]); |
44 | set_random_name_and_status_message(tox2, name2, status_message2); | 44 | set_random_name_and_status_message(tox2, name2, status_message2); |
45 | 45 | ||
46 | uint8_t address[TOX_ADDRESS_SIZE]; | 46 | uint8_t address[TOX_ADDRESS_SIZE]; |
@@ -51,7 +51,7 @@ START_TEST(test_one) | |||
51 | 51 | ||
52 | tox_self_get_address(tox2, address); | 52 | tox_self_get_address(tox2, address); |
53 | uint8_t message[TOX_MAX_FRIEND_REQUEST_LENGTH + 1]; | 53 | uint8_t message[TOX_MAX_FRIEND_REQUEST_LENGTH + 1]; |
54 | ret = tox_friend_add(tox1, address, NULL, 0, &error); | 54 | ret = tox_friend_add(tox1, address, nullptr, 0, &error); |
55 | ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_NULL, "Sending request with no message worked."); | 55 | ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_NULL, "Sending request with no message worked."); |
56 | ret = tox_friend_add(tox1, address, message, 0, &error); | 56 | ret = tox_friend_add(tox1, address, message, 0, &error); |
57 | ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_NO_MESSAGE, "Sending request with no message worked."); | 57 | ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_NO_MESSAGE, "Sending request with no message worked."); |
@@ -70,10 +70,10 @@ START_TEST(test_one) | |||
70 | ret = tox_friend_add(tox1, address, message, TOX_MAX_FRIEND_REQUEST_LENGTH, &error); | 70 | ret = tox_friend_add(tox1, address, message, TOX_MAX_FRIEND_REQUEST_LENGTH, &error); |
71 | ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_ALREADY_SENT, "Adding friend twice worked."); | 71 | ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_ALREADY_SENT, "Adding friend twice worked."); |
72 | 72 | ||
73 | tox_self_set_name(tox1, name, sizeof(name), 0); | 73 | tox_self_set_name(tox1, name, sizeof(name), nullptr); |
74 | ck_assert_msg(tox_self_get_name_size(tox1) == sizeof(name), "Can't set name of TOX_MAX_NAME_LENGTH"); | 74 | ck_assert_msg(tox_self_get_name_size(tox1) == sizeof(name), "Can't set name of TOX_MAX_NAME_LENGTH"); |
75 | 75 | ||
76 | tox_self_set_status_message(tox1, status_message, sizeof(status_message), 0); | 76 | tox_self_set_status_message(tox1, status_message, sizeof(status_message), nullptr); |
77 | ck_assert_msg(tox_self_get_status_message_size(tox1) == sizeof(status_message), | 77 | ck_assert_msg(tox_self_get_status_message_size(tox1) == sizeof(status_message), |
78 | "Can't set status message of TOX_MAX_STATUS_MESSAGE_LENGTH"); | 78 | "Can't set status message of TOX_MAX_STATUS_MESSAGE_LENGTH"); |
79 | 79 | ||
@@ -85,7 +85,7 @@ START_TEST(test_one) | |||
85 | tox_kill(tox2); | 85 | tox_kill(tox2); |
86 | TOX_ERR_NEW err_n; | 86 | TOX_ERR_NEW err_n; |
87 | 87 | ||
88 | struct Tox_Options *options = tox_options_new(NULL); | 88 | struct Tox_Options *options = tox_options_new(nullptr); |
89 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); | 89 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); |
90 | tox_options_set_savedata_data(options, data, save_size); | 90 | tox_options_set_savedata_data(options, data, save_size); |
91 | tox2 = tox_new_log(options, &err_n, &index[1]); | 91 | tox2 = tox_new_log(options, &err_n, &index[1]); |
@@ -151,7 +151,7 @@ static Suite *tox_suite(void) | |||
151 | 151 | ||
152 | int main(int argc, char *argv[]) | 152 | int main(int argc, char *argv[]) |
153 | { | 153 | { |
154 | srand((unsigned int) time(NULL)); | 154 | srand((unsigned int) time(nullptr)); |
155 | 155 | ||
156 | Suite *tox = tox_suite(); | 156 | Suite *tox = tox_suite(); |
157 | SRunner *test_runner = srunner_create(tox); | 157 | SRunner *test_runner = srunner_create(tox); |
diff --git a/auto_tests/tox_strncasecmp_test.c b/auto_tests/tox_strncasecmp_test.c index c9ad696a..3a544c00 100644 --- a/auto_tests/tox_strncasecmp_test.c +++ b/auto_tests/tox_strncasecmp_test.c | |||
@@ -179,7 +179,7 @@ static Suite *tox_strncasecmp_suite(void) | |||
179 | 179 | ||
180 | int main(int argc, char *argv[]) | 180 | int main(int argc, char *argv[]) |
181 | { | 181 | { |
182 | srand((unsigned int) time(NULL)); | 182 | srand((unsigned int) time(nullptr)); |
183 | 183 | ||
184 | Suite *s = tox_strncasecmp_suite(); | 184 | Suite *s = tox_strncasecmp_suite(); |
185 | SRunner *test_runner = srunner_create(s); | 185 | SRunner *test_runner = srunner_create(s); |
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index c66f0bc9..be6da1d4 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -10,7 +10,9 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #ifndef _XOPEN_SOURCE | ||
13 | #define _XOPEN_SOURCE 600 | 14 | #define _XOPEN_SOURCE 600 |
15 | #endif | ||
14 | 16 | ||
15 | #ifdef HAVE_CONFIG_H | 17 | #ifdef HAVE_CONFIG_H |
16 | #include "config.h" | 18 | #include "config.h" |
@@ -43,7 +45,7 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
43 | } | 45 | } |
44 | 46 | ||
45 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { | 47 | if (length == 7 && memcmp("Gentoo", data, 7) == 0) { |
46 | tox_friend_add_norequest(m, public_key, 0); | 48 | tox_friend_add_norequest(m, public_key, nullptr); |
47 | } | 49 | } |
48 | } | 50 | } |
49 | static uint32_t messages_received; | 51 | static uint32_t messages_received; |
@@ -154,7 +156,7 @@ static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_num | |||
154 | 156 | ||
155 | uint8_t file_id[TOX_FILE_ID_LENGTH]; | 157 | uint8_t file_id[TOX_FILE_ID_LENGTH]; |
156 | 158 | ||
157 | if (!tox_file_get_file_id(tox, friend_number, file_number, file_id, 0)) { | 159 | if (!tox_file_get_file_id(tox, friend_number, file_number, file_id, nullptr)) { |
158 | ck_abort_msg("tox_file_get_file_id error"); | 160 | ck_abort_msg("tox_file_get_file_id error"); |
159 | } | 161 | } |
160 | 162 | ||
@@ -318,13 +320,13 @@ static void tox_connection_status(Tox *tox, TOX_CONNECTION connection_status, vo | |||
318 | START_TEST(test_few_clients) | 320 | START_TEST(test_few_clients) |
319 | { | 321 | { |
320 | uint32_t index[] = { 1, 2, 3 }; | 322 | uint32_t index[] = { 1, 2, 3 }; |
321 | long long unsigned int con_time = 0, cur_time = time(NULL); | 323 | long long unsigned int con_time = 0, cur_time = time(nullptr); |
322 | TOX_ERR_NEW t_n_error; | 324 | TOX_ERR_NEW t_n_error; |
323 | Tox *tox1 = tox_new_log(0, &t_n_error, &index[0]); | 325 | Tox *tox1 = tox_new_log(nullptr, &t_n_error, &index[0]); |
324 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 326 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
325 | Tox *tox2 = tox_new_log(0, &t_n_error, &index[1]); | 327 | Tox *tox2 = tox_new_log(nullptr, &t_n_error, &index[1]); |
326 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 328 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
327 | Tox *tox3 = tox_new_log(0, &t_n_error, &index[2]); | 329 | Tox *tox3 = tox_new_log(nullptr, &t_n_error, &index[2]); |
328 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 330 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
329 | 331 | ||
330 | ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances"); | 332 | ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances"); |
@@ -351,7 +353,7 @@ START_TEST(test_few_clients) | |||
351 | tox_callback_friend_request(tox2, accept_friend_request); | 353 | tox_callback_friend_request(tox2, accept_friend_request); |
352 | uint8_t address[TOX_ADDRESS_SIZE]; | 354 | uint8_t address[TOX_ADDRESS_SIZE]; |
353 | tox_self_get_address(tox2, address); | 355 | tox_self_get_address(tox2, address); |
354 | uint32_t test = tox_friend_add(tox3, address, (const uint8_t *)"Gentoo", 7, 0); | 356 | uint32_t test = tox_friend_add(tox3, address, (const uint8_t *)"Gentoo", 7, nullptr); |
355 | ck_assert_msg(test == 0, "Failed to add friend error code: %i", test); | 357 | ck_assert_msg(test == 0, "Failed to add friend error code: %i", test); |
356 | 358 | ||
357 | uint8_t off = 1; | 359 | uint8_t off = 1; |
@@ -364,13 +366,13 @@ START_TEST(test_few_clients) | |||
364 | if (tox_self_get_connection_status(tox1) && tox_self_get_connection_status(tox2) | 366 | if (tox_self_get_connection_status(tox1) && tox_self_get_connection_status(tox2) |
365 | && tox_self_get_connection_status(tox3)) { | 367 | && tox_self_get_connection_status(tox3)) { |
366 | if (off) { | 368 | if (off) { |
367 | printf("Toxes are online, took %llu seconds\n", time(NULL) - cur_time); | 369 | printf("Toxes are online, took %llu seconds\n", time(nullptr) - cur_time); |
368 | con_time = time(NULL); | 370 | con_time = time(nullptr); |
369 | off = 0; | 371 | off = 0; |
370 | } | 372 | } |
371 | 373 | ||
372 | if (tox_friend_get_connection_status(tox2, 0, 0) == TOX_CONNECTION_UDP | 374 | if (tox_friend_get_connection_status(tox2, 0, nullptr) == TOX_CONNECTION_UDP |
373 | && tox_friend_get_connection_status(tox3, 0, 0) == TOX_CONNECTION_UDP) { | 375 | && tox_friend_get_connection_status(tox3, 0, nullptr) == TOX_CONNECTION_UDP) { |
374 | break; | 376 | break; |
375 | } | 377 | } |
376 | } | 378 | } |
@@ -379,7 +381,7 @@ START_TEST(test_few_clients) | |||
379 | } | 381 | } |
380 | 382 | ||
381 | ck_assert_msg(connected_t1, "Tox1 isn't connected. %u", connected_t1); | 383 | ck_assert_msg(connected_t1, "Tox1 isn't connected. %u", connected_t1); |
382 | printf("tox clients connected took %llu seconds\n", time(NULL) - con_time); | 384 | printf("tox clients connected took %llu seconds\n", time(nullptr) - con_time); |
383 | to_compare = 974536; | 385 | to_compare = 974536; |
384 | tox_callback_friend_message(tox3, print_message); | 386 | tox_callback_friend_message(tox3, print_message); |
385 | uint8_t msgs[TOX_MAX_MESSAGE_LENGTH + 1]; | 387 | uint8_t msgs[TOX_MAX_MESSAGE_LENGTH + 1]; |
@@ -412,11 +414,11 @@ START_TEST(test_few_clients) | |||
412 | tox_get_savedata(tox2, save1); | 414 | tox_get_savedata(tox2, save1); |
413 | tox_kill(tox2); | 415 | tox_kill(tox2); |
414 | 416 | ||
415 | struct Tox_Options *options = tox_options_new(NULL); | 417 | struct Tox_Options *options = tox_options_new(nullptr); |
416 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); | 418 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); |
417 | tox_options_set_savedata_data(options, save1, save_size1); | 419 | tox_options_set_savedata_data(options, save1, save_size1); |
418 | tox2 = tox_new_log(options, NULL, &index[1]); | 420 | tox2 = tox_new_log(options, nullptr, &index[1]); |
419 | cur_time = time(NULL); | 421 | cur_time = time(nullptr); |
420 | off = 1; | 422 | off = 1; |
421 | 423 | ||
422 | while (1) { | 424 | while (1) { |
@@ -427,13 +429,13 @@ START_TEST(test_few_clients) | |||
427 | if (tox_self_get_connection_status(tox1) && tox_self_get_connection_status(tox2) | 429 | if (tox_self_get_connection_status(tox1) && tox_self_get_connection_status(tox2) |
428 | && tox_self_get_connection_status(tox3)) { | 430 | && tox_self_get_connection_status(tox3)) { |
429 | if (off) { | 431 | if (off) { |
430 | printf("Toxes are online again after reloading, took %llu seconds\n", time(NULL) - cur_time); | 432 | printf("Toxes are online again after reloading, took %llu seconds\n", time(nullptr) - cur_time); |
431 | con_time = time(NULL); | 433 | con_time = time(nullptr); |
432 | off = 0; | 434 | off = 0; |
433 | } | 435 | } |
434 | 436 | ||
435 | if (tox_friend_get_connection_status(tox2, 0, 0) == TOX_CONNECTION_UDP | 437 | if (tox_friend_get_connection_status(tox2, 0, nullptr) == TOX_CONNECTION_UDP |
436 | && tox_friend_get_connection_status(tox3, 0, 0) == TOX_CONNECTION_UDP) { | 438 | && tox_friend_get_connection_status(tox3, 0, nullptr) == TOX_CONNECTION_UDP) { |
437 | break; | 439 | break; |
438 | } | 440 | } |
439 | } | 441 | } |
@@ -441,7 +443,7 @@ START_TEST(test_few_clients) | |||
441 | c_sleep(50); | 443 | c_sleep(50); |
442 | } | 444 | } |
443 | 445 | ||
444 | printf("tox clients connected took %llu seconds\n", time(NULL) - con_time); | 446 | printf("tox clients connected took %llu seconds\n", time(nullptr) - con_time); |
445 | tox_callback_friend_name(tox3, print_nickchange); | 447 | tox_callback_friend_name(tox3, print_nickchange); |
446 | TOX_ERR_SET_INFO err_n; | 448 | TOX_ERR_SET_INFO err_n; |
447 | bool succ = tox_self_set_name(tox2, (const uint8_t *)"Gentoo", sizeof("Gentoo"), &err_n); | 449 | bool succ = tox_self_set_name(tox2, (const uint8_t *)"Gentoo", sizeof("Gentoo"), &err_n); |
@@ -460,9 +462,9 @@ START_TEST(test_few_clients) | |||
460 | c_sleep(50); | 462 | c_sleep(50); |
461 | } | 463 | } |
462 | 464 | ||
463 | ck_assert_msg(tox_friend_get_name_size(tox3, 0, 0) == sizeof("Gentoo"), "Name length not correct"); | 465 | ck_assert_msg(tox_friend_get_name_size(tox3, 0, nullptr) == sizeof("Gentoo"), "Name length not correct"); |
464 | uint8_t temp_name[sizeof("Gentoo")]; | 466 | uint8_t temp_name[sizeof("Gentoo")]; |
465 | tox_friend_get_name(tox3, 0, temp_name, 0); | 467 | tox_friend_get_name(tox3, 0, temp_name, nullptr); |
466 | ck_assert_msg(memcmp(temp_name, "Gentoo", sizeof("Gentoo")) == 0, "Name not correct"); | 468 | ck_assert_msg(memcmp(temp_name, "Gentoo", sizeof("Gentoo")) == 0, "Name not correct"); |
467 | 469 | ||
468 | tox_callback_friend_status_message(tox3, print_status_m_change); | 470 | tox_callback_friend_status_message(tox3, print_status_m_change); |
@@ -482,15 +484,15 @@ START_TEST(test_few_clients) | |||
482 | c_sleep(50); | 484 | c_sleep(50); |
483 | } | 485 | } |
484 | 486 | ||
485 | ck_assert_msg(tox_friend_get_status_message_size(tox3, 0, 0) == sizeof("Installing Gentoo"), | 487 | ck_assert_msg(tox_friend_get_status_message_size(tox3, 0, nullptr) == sizeof("Installing Gentoo"), |
486 | "status message length not correct"); | 488 | "status message length not correct"); |
487 | uint8_t temp_status_m[sizeof("Installing Gentoo")]; | 489 | uint8_t temp_status_m[sizeof("Installing Gentoo")]; |
488 | tox_friend_get_status_message(tox3, 0, temp_status_m, 0); | 490 | tox_friend_get_status_message(tox3, 0, temp_status_m, nullptr); |
489 | ck_assert_msg(memcmp(temp_status_m, "Installing Gentoo", sizeof("Installing Gentoo")) == 0, | 491 | ck_assert_msg(memcmp(temp_status_m, "Installing Gentoo", sizeof("Installing Gentoo")) == 0, |
490 | "status message not correct"); | 492 | "status message not correct"); |
491 | 493 | ||
492 | tox_callback_friend_typing(tox2, &print_typingchange); | 494 | tox_callback_friend_typing(tox2, &print_typingchange); |
493 | tox_self_set_typing(tox3, 0, 1, 0); | 495 | tox_self_set_typing(tox3, 0, 1, nullptr); |
494 | 496 | ||
495 | while (1) { | 497 | while (1) { |
496 | typing_changes = 0; | 498 | typing_changes = 0; |
@@ -507,8 +509,8 @@ START_TEST(test_few_clients) | |||
507 | c_sleep(50); | 509 | c_sleep(50); |
508 | } | 510 | } |
509 | 511 | ||
510 | ck_assert_msg(tox_friend_get_typing(tox2, 0, 0) == 1, "Typing fail"); | 512 | ck_assert_msg(tox_friend_get_typing(tox2, 0, nullptr) == 1, "Typing fail"); |
511 | tox_self_set_typing(tox3, 0, 0, 0); | 513 | tox_self_set_typing(tox3, 0, 0, nullptr); |
512 | 514 | ||
513 | while (1) { | 515 | while (1) { |
514 | typing_changes = 0; | 516 | typing_changes = 0; |
@@ -533,9 +535,9 @@ START_TEST(test_few_clients) | |||
533 | tox_callback_friend_lossless_packet(tox3, &handle_custom_packet); | 535 | tox_callback_friend_lossless_packet(tox3, &handle_custom_packet); |
534 | uint8_t data_c[TOX_MAX_CUSTOM_PACKET_SIZE + 1]; | 536 | uint8_t data_c[TOX_MAX_CUSTOM_PACKET_SIZE + 1]; |
535 | memset(data_c, ((uint8_t)packet_number), sizeof(data_c)); | 537 | memset(data_c, ((uint8_t)packet_number), sizeof(data_c)); |
536 | int ret = tox_friend_send_lossless_packet(tox2, 0, data_c, sizeof(data_c), 0); | 538 | int ret = tox_friend_send_lossless_packet(tox2, 0, data_c, sizeof(data_c), nullptr); |
537 | ck_assert_msg(ret == 0, "tox_friend_send_lossless_packet bigger fail %i", ret); | 539 | ck_assert_msg(ret == 0, "tox_friend_send_lossless_packet bigger fail %i", ret); |
538 | ret = tox_friend_send_lossless_packet(tox2, 0, data_c, TOX_MAX_CUSTOM_PACKET_SIZE, 0); | 540 | ret = tox_friend_send_lossless_packet(tox2, 0, data_c, TOX_MAX_CUSTOM_PACKET_SIZE, nullptr); |
539 | ck_assert_msg(ret == 1, "tox_friend_send_lossless_packet fail %i", ret); | 541 | ck_assert_msg(ret == 1, "tox_friend_send_lossless_packet fail %i", ret); |
540 | 542 | ||
541 | while (1) { | 543 | while (1) { |
@@ -556,9 +558,9 @@ START_TEST(test_few_clients) | |||
556 | packet_number = 200; | 558 | packet_number = 200; |
557 | tox_callback_friend_lossy_packet(tox3, &handle_custom_packet); | 559 | tox_callback_friend_lossy_packet(tox3, &handle_custom_packet); |
558 | memset(data_c, ((uint8_t)packet_number), sizeof(data_c)); | 560 | memset(data_c, ((uint8_t)packet_number), sizeof(data_c)); |
559 | ret = tox_friend_send_lossy_packet(tox2, 0, data_c, sizeof(data_c), 0); | 561 | ret = tox_friend_send_lossy_packet(tox2, 0, data_c, sizeof(data_c), nullptr); |
560 | ck_assert_msg(ret == 0, "tox_friend_send_lossy_packet bigger fail %i", ret); | 562 | ck_assert_msg(ret == 0, "tox_friend_send_lossy_packet bigger fail %i", ret); |
561 | ret = tox_friend_send_lossy_packet(tox2, 0, data_c, TOX_MAX_CUSTOM_PACKET_SIZE, 0); | 563 | ret = tox_friend_send_lossy_packet(tox2, 0, data_c, TOX_MAX_CUSTOM_PACKET_SIZE, nullptr); |
562 | ck_assert_msg(ret == 1, "tox_friend_send_lossy_packet fail %i", ret); | 564 | ck_assert_msg(ret == 1, "tox_friend_send_lossy_packet fail %i", ret); |
563 | 565 | ||
564 | while (1) { | 566 | while (1) { |
@@ -581,15 +583,15 @@ START_TEST(test_few_clients) | |||
581 | file_accepted = file_size = sendf_ok = size_recv = 0; | 583 | file_accepted = file_size = sendf_ok = size_recv = 0; |
582 | file_recv = 0; | 584 | file_recv = 0; |
583 | max_sending = UINT64_MAX; | 585 | max_sending = UINT64_MAX; |
584 | long long unsigned int f_time = time(NULL); | 586 | long long unsigned int f_time = time(nullptr); |
585 | tox_callback_file_recv_chunk(tox3, write_file); | 587 | tox_callback_file_recv_chunk(tox3, write_file); |
586 | tox_callback_file_recv_control(tox2, file_print_control); | 588 | tox_callback_file_recv_control(tox2, file_print_control); |
587 | tox_callback_file_chunk_request(tox2, tox_file_chunk_request); | 589 | tox_callback_file_chunk_request(tox2, tox_file_chunk_request); |
588 | tox_callback_file_recv_control(tox3, file_print_control); | 590 | tox_callback_file_recv_control(tox3, file_print_control); |
589 | tox_callback_file_recv(tox3, tox_file_receive); | 591 | tox_callback_file_recv(tox3, tox_file_receive); |
590 | uint64_t totalf_size = 100 * 1024 * 1024; | 592 | uint64_t totalf_size = 100 * 1024 * 1024; |
591 | uint32_t fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, 0, (const uint8_t *)"Gentoo.exe", | 593 | uint32_t fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr, (const uint8_t *)"Gentoo.exe", |
592 | sizeof("Gentoo.exe"), 0); | 594 | sizeof("Gentoo.exe"), nullptr); |
593 | ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail"); | 595 | ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail"); |
594 | 596 | ||
595 | TOX_ERR_FILE_GET gfierr; | 597 | TOX_ERR_FILE_GET gfierr; |
@@ -623,7 +625,7 @@ START_TEST(test_few_clients) | |||
623 | c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval))); | 625 | c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval))); |
624 | } | 626 | } |
625 | 627 | ||
626 | printf("100MB file sent in %llu seconds\n", time(NULL) - f_time); | 628 | printf("100MB file sent in %llu seconds\n", time(nullptr) - f_time); |
627 | 629 | ||
628 | printf("Starting file streaming transfer test.\n"); | 630 | printf("Starting file streaming transfer test.\n"); |
629 | 631 | ||
@@ -635,8 +637,8 @@ START_TEST(test_few_clients) | |||
635 | tox_callback_file_recv_control(tox3, file_print_control); | 637 | tox_callback_file_recv_control(tox3, file_print_control); |
636 | tox_callback_file_recv(tox3, tox_file_receive); | 638 | tox_callback_file_recv(tox3, tox_file_receive); |
637 | totalf_size = UINT64_MAX; | 639 | totalf_size = UINT64_MAX; |
638 | fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, 0, (const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), | 640 | fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr, |
639 | 0); | 641 | (const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr); |
640 | ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail"); | 642 | ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail"); |
641 | 643 | ||
642 | ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail"); | 644 | ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail"); |
@@ -683,8 +685,8 @@ START_TEST(test_few_clients) | |||
683 | tox_callback_file_recv_control(tox3, file_print_control); | 685 | tox_callback_file_recv_control(tox3, file_print_control); |
684 | tox_callback_file_recv(tox3, tox_file_receive); | 686 | tox_callback_file_recv(tox3, tox_file_receive); |
685 | totalf_size = 0; | 687 | totalf_size = 0; |
686 | fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, 0, (const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), | 688 | fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr, |
687 | 0); | 689 | (const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr); |
688 | ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail"); | 690 | ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail"); |
689 | 691 | ||
690 | ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail"); | 692 | ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail"); |
@@ -717,7 +719,7 @@ START_TEST(test_few_clients) | |||
717 | c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval))); | 719 | c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval))); |
718 | } | 720 | } |
719 | 721 | ||
720 | printf("test_few_clients succeeded, took %llu seconds\n", time(NULL) - cur_time); | 722 | printf("test_few_clients succeeded, took %llu seconds\n", time(nullptr) - cur_time); |
721 | 723 | ||
722 | tox_options_free(options); | 724 | tox_options_free(options); |
723 | tox_kill(tox1); | 725 | tox_kill(tox1); |
@@ -743,7 +745,7 @@ static Suite *tox_suite(void) | |||
743 | 745 | ||
744 | int main(int argc, char *argv[]) | 746 | int main(int argc, char *argv[]) |
745 | { | 747 | { |
746 | srand((unsigned int) time(NULL)); | 748 | srand((unsigned int) time(nullptr)); |
747 | 749 | ||
748 | Suite *tox = tox_suite(); | 750 | Suite *tox = tox_suite(); |
749 | SRunner *test_runner = srunner_create(tox); | 751 | SRunner *test_runner = srunner_create(tox); |
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index d21df613..c192f556 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #ifndef _XOPEN_SOURCE | ||
1 | #define _XOPEN_SOURCE 600 | 2 | #define _XOPEN_SOURCE 600 |
3 | #endif | ||
2 | 4 | ||
3 | #ifdef HAVE_CONFIG_H | 5 | #ifdef HAVE_CONFIG_H |
4 | #include "config.h" | 6 | #include "config.h" |
@@ -112,7 +114,7 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const | |||
112 | (void) userdata; | 114 | (void) userdata; |
113 | 115 | ||
114 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { | 116 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { |
115 | ck_assert(tox_friend_add_norequest(m, public_key, NULL) != (uint32_t) ~0); | 117 | ck_assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) ~0); |
116 | } | 118 | } |
117 | } | 119 | } |
118 | 120 | ||
@@ -123,9 +125,9 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const | |||
123 | static int iterate_tox(Tox *bootstrap, Tox *Alice, Tox *Bob) | 125 | static int iterate_tox(Tox *bootstrap, Tox *Alice, Tox *Bob) |
124 | { | 126 | { |
125 | c_sleep(100); | 127 | c_sleep(100); |
126 | tox_iterate(bootstrap, NULL); | 128 | tox_iterate(bootstrap, nullptr); |
127 | tox_iterate(Alice, NULL); | 129 | tox_iterate(Alice, nullptr); |
128 | tox_iterate(Bob, NULL); | 130 | tox_iterate(Bob, nullptr); |
129 | 131 | ||
130 | return MIN(tox_iteration_interval(Alice), tox_iteration_interval(Bob)); | 132 | return MIN(tox_iteration_interval(Alice), tox_iteration_interval(Bob)); |
131 | } | 133 | } |
@@ -143,19 +145,19 @@ START_TEST(test_AV_flows) | |||
143 | { | 145 | { |
144 | TOX_ERR_NEW error; | 146 | TOX_ERR_NEW error; |
145 | 147 | ||
146 | bootstrap = tox_new_log(NULL, &error, &index[0]); | 148 | bootstrap = tox_new_log(nullptr, &error, &index[0]); |
147 | ck_assert(error == TOX_ERR_NEW_OK); | 149 | ck_assert(error == TOX_ERR_NEW_OK); |
148 | 150 | ||
149 | Alice = tox_new_log(NULL, &error, &index[1]); | 151 | Alice = tox_new_log(nullptr, &error, &index[1]); |
150 | ck_assert(error == TOX_ERR_NEW_OK); | 152 | ck_assert(error == TOX_ERR_NEW_OK); |
151 | 153 | ||
152 | Bob = tox_new_log(NULL, &error, &index[2]); | 154 | Bob = tox_new_log(nullptr, &error, &index[2]); |
153 | ck_assert(error == TOX_ERR_NEW_OK); | 155 | ck_assert(error == TOX_ERR_NEW_OK); |
154 | } | 156 | } |
155 | 157 | ||
156 | printf("Created 3 instances of Tox\n"); | 158 | printf("Created 3 instances of Tox\n"); |
157 | printf("Preparing network...\n"); | 159 | printf("Preparing network...\n"); |
158 | long long unsigned int cur_time = time(NULL); | 160 | long long unsigned int cur_time = time(nullptr); |
159 | 161 | ||
160 | uint8_t address[TOX_ADDRESS_SIZE]; | 162 | uint8_t address[TOX_ADDRESS_SIZE]; |
161 | 163 | ||
@@ -163,7 +165,7 @@ START_TEST(test_AV_flows) | |||
163 | tox_self_get_address(Alice, address); | 165 | tox_self_get_address(Alice, address); |
164 | 166 | ||
165 | 167 | ||
166 | ck_assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); | 168 | ck_assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); |
167 | 169 | ||
168 | uint8_t off = 1; | 170 | uint8_t off = 1; |
169 | 171 | ||
@@ -173,12 +175,12 @@ START_TEST(test_AV_flows) | |||
173 | if (tox_self_get_connection_status(bootstrap) && | 175 | if (tox_self_get_connection_status(bootstrap) && |
174 | tox_self_get_connection_status(Alice) && | 176 | tox_self_get_connection_status(Alice) && |
175 | tox_self_get_connection_status(Bob) && off) { | 177 | tox_self_get_connection_status(Bob) && off) { |
176 | printf("Toxes are online, took %llu seconds\n", time(NULL) - cur_time); | 178 | printf("Toxes are online, took %llu seconds\n", time(nullptr) - cur_time); |
177 | off = 0; | 179 | off = 0; |
178 | } | 180 | } |
179 | 181 | ||
180 | if (tox_friend_get_connection_status(Alice, 0, NULL) == TOX_CONNECTION_UDP && | 182 | if (tox_friend_get_connection_status(Alice, 0, nullptr) == TOX_CONNECTION_UDP && |
181 | tox_friend_get_connection_status(Bob, 0, NULL) == TOX_CONNECTION_UDP) { | 183 | tox_friend_get_connection_status(Bob, 0, nullptr) == TOX_CONNECTION_UDP) { |
182 | break; | 184 | break; |
183 | } | 185 | } |
184 | 186 | ||
@@ -206,7 +208,7 @@ START_TEST(test_AV_flows) | |||
206 | toxav_callback_audio_receive_frame(BobAV, t_toxav_receive_audio_frame_cb, &BobCC); | 208 | toxav_callback_audio_receive_frame(BobAV, t_toxav_receive_audio_frame_cb, &BobCC); |
207 | 209 | ||
208 | printf("Created 2 instances of ToxAV\n"); | 210 | printf("Created 2 instances of ToxAV\n"); |
209 | printf("All set after %llu seconds!\n", time(NULL) - cur_time); | 211 | printf("All set after %llu seconds!\n", time(nullptr) - cur_time); |
210 | 212 | ||
211 | 213 | ||
212 | #define REGULAR_CALL_FLOW(A_BR, V_BR) \ | 214 | #define REGULAR_CALL_FLOW(A_BR, V_BR) \ |
@@ -223,7 +225,7 @@ START_TEST(test_AV_flows) | |||
223 | } \ | 225 | } \ |
224 | \ | 226 | \ |
225 | \ | 227 | \ |
226 | long long unsigned int start_time = time(NULL); \ | 228 | long long unsigned int start_time = time(nullptr); \ |
227 | \ | 229 | \ |
228 | \ | 230 | \ |
229 | while (BobCC.state != TOXAV_FRIEND_CALL_STATE_FINISHED) { \ | 231 | while (BobCC.state != TOXAV_FRIEND_CALL_STATE_FINISHED) { \ |
@@ -240,7 +242,7 @@ START_TEST(test_AV_flows) | |||
240 | } else { \ | 242 | } else { \ |
241 | /* TODO(mannol): rtp */ \ | 243 | /* TODO(mannol): rtp */ \ |
242 | \ | 244 | \ |
243 | if (time(NULL) - start_time >= 1) { \ | 245 | if (time(nullptr) - start_time >= 1) { \ |
244 | \ | 246 | \ |
245 | TOXAV_ERR_CALL_CONTROL cc_err; \ | 247 | TOXAV_ERR_CALL_CONTROL cc_err; \ |
246 | toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_CANCEL, &cc_err); \ | 248 | toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_CANCEL, &cc_err); \ |
@@ -373,12 +375,12 @@ START_TEST(test_AV_flows) | |||
373 | } | 375 | } |
374 | 376 | ||
375 | /* At first try all stuff while in invalid state */ | 377 | /* At first try all stuff while in invalid state */ |
376 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_PAUSE, NULL)); | 378 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_PAUSE, nullptr)); |
377 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_RESUME, NULL)); | 379 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_RESUME, nullptr)); |
378 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_MUTE_AUDIO, NULL)); | 380 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_MUTE_AUDIO, nullptr)); |
379 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_UNMUTE_AUDIO, NULL)); | 381 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_UNMUTE_AUDIO, nullptr)); |
380 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_HIDE_VIDEO, NULL)); | 382 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_HIDE_VIDEO, nullptr)); |
381 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_SHOW_VIDEO, NULL)); | 383 | ck_assert(!toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_SHOW_VIDEO, nullptr)); |
382 | 384 | ||
383 | { | 385 | { |
384 | TOXAV_ERR_ANSWER rc; | 386 | TOXAV_ERR_ANSWER rc; |
@@ -476,19 +478,19 @@ START_TEST(test_AV_flows) | |||
476 | 478 | ||
477 | printf("Call started as audio only\n"); | 479 | printf("Call started as audio only\n"); |
478 | printf("Turning on video for Alice...\n"); | 480 | printf("Turning on video for Alice...\n"); |
479 | ck_assert(toxav_video_set_bit_rate(AliceAV, 0, 1000, NULL)); | 481 | ck_assert(toxav_video_set_bit_rate(AliceAV, 0, 1000, nullptr)); |
480 | 482 | ||
481 | iterate_tox(bootstrap, Alice, Bob); | 483 | iterate_tox(bootstrap, Alice, Bob); |
482 | ck_assert(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_V); | 484 | ck_assert(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_V); |
483 | 485 | ||
484 | printf("Turning off video for Alice...\n"); | 486 | printf("Turning off video for Alice...\n"); |
485 | ck_assert(toxav_video_set_bit_rate(AliceAV, 0, 0, NULL)); | 487 | ck_assert(toxav_video_set_bit_rate(AliceAV, 0, 0, nullptr)); |
486 | 488 | ||
487 | iterate_tox(bootstrap, Alice, Bob); | 489 | iterate_tox(bootstrap, Alice, Bob); |
488 | ck_assert(!(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_V)); | 490 | ck_assert(!(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_V)); |
489 | 491 | ||
490 | printf("Turning off audio for Alice...\n"); | 492 | printf("Turning off audio for Alice...\n"); |
491 | ck_assert(toxav_audio_set_bit_rate(AliceAV, 0, 0, NULL)); | 493 | ck_assert(toxav_audio_set_bit_rate(AliceAV, 0, 0, nullptr)); |
492 | 494 | ||
493 | iterate_tox(bootstrap, Alice, Bob); | 495 | iterate_tox(bootstrap, Alice, Bob); |
494 | ck_assert(!(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_A)); | 496 | ck_assert(!(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_A)); |
@@ -545,12 +547,12 @@ START_TEST(test_AV_flows) | |||
545 | iterate_tox(bootstrap, Alice, Bob); | 547 | iterate_tox(bootstrap, Alice, Bob); |
546 | ck_assert_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_PAUSE); | 548 | ck_assert_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_PAUSE); |
547 | iterate_tox(bootstrap, Alice, Bob); | 549 | iterate_tox(bootstrap, Alice, Bob); |
548 | ck_assert(!toxav_audio_send_frame(AliceAV, 0, PCM, 960, 1, 48000, NULL)); | 550 | ck_assert(!toxav_audio_send_frame(AliceAV, 0, PCM, 960, 1, 48000, nullptr)); |
549 | ck_assert(!toxav_audio_send_frame(BobAV, 0, PCM, 960, 1, 48000, NULL)); | 551 | ck_assert(!toxav_audio_send_frame(BobAV, 0, PCM, 960, 1, 48000, nullptr)); |
550 | ck_assert_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_RESUME); | 552 | ck_assert_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_RESUME); |
551 | iterate_tox(bootstrap, Alice, Bob); | 553 | iterate_tox(bootstrap, Alice, Bob); |
552 | ck_assert(toxav_audio_send_frame(AliceAV, 0, PCM, 960, 1, 48000, NULL)); | 554 | ck_assert(toxav_audio_send_frame(AliceAV, 0, PCM, 960, 1, 48000, nullptr)); |
553 | ck_assert(toxav_audio_send_frame(BobAV, 0, PCM, 960, 1, 48000, NULL)); | 555 | ck_assert(toxav_audio_send_frame(BobAV, 0, PCM, 960, 1, 48000, nullptr)); |
554 | iterate_tox(bootstrap, Alice, Bob); | 556 | iterate_tox(bootstrap, Alice, Bob); |
555 | 557 | ||
556 | { | 558 | { |
@@ -594,7 +596,7 @@ int main(int argc, char *argv[]) | |||
594 | Suite *tox = tox_suite(); | 596 | Suite *tox = tox_suite(); |
595 | SRunner *test_runner = srunner_create(tox); | 597 | SRunner *test_runner = srunner_create(tox); |
596 | 598 | ||
597 | setbuf(stdout, NULL); | 599 | setbuf(stdout, nullptr); |
598 | 600 | ||
599 | srunner_run_all(test_runner, CK_NORMAL); | 601 | srunner_run_all(test_runner, CK_NORMAL); |
600 | int number_failed = srunner_ntests_failed(test_runner); | 602 | int number_failed = srunner_ntests_failed(test_runner); |
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 5796905c..9a639eb8 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #ifndef _XOPEN_SOURCE | ||
1 | #define _XOPEN_SOURCE 600 | 2 | #define _XOPEN_SOURCE 600 |
3 | #endif | ||
2 | 4 | ||
3 | #ifdef HAVE_CONFIG_H | 5 | #ifdef HAVE_CONFIG_H |
4 | #include "config.h" | 6 | #include "config.h" |
@@ -96,7 +98,7 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const | |||
96 | (void) userdata; | 98 | (void) userdata; |
97 | 99 | ||
98 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { | 100 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { |
99 | ck_assert(tox_friend_add_norequest(m, public_key, NULL) != (uint32_t) ~0); | 101 | ck_assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) ~0); |
100 | } | 102 | } |
101 | } | 103 | } |
102 | 104 | ||
@@ -160,17 +162,17 @@ static void *call_thread(void *pd) | |||
160 | uint8_t *video_u = (uint8_t *)calloc(800 * 600 / 4, sizeof(uint8_t)); | 162 | uint8_t *video_u = (uint8_t *)calloc(800 * 600 / 4, sizeof(uint8_t)); |
161 | uint8_t *video_v = (uint8_t *)calloc(800 * 600 / 4, sizeof(uint8_t)); | 163 | uint8_t *video_v = (uint8_t *)calloc(800 * 600 / 4, sizeof(uint8_t)); |
162 | 164 | ||
163 | time_t start_time = time(NULL); | 165 | time_t start_time = time(nullptr); |
164 | 166 | ||
165 | while (time(NULL) - start_time < 4) { | 167 | while (time(nullptr) - start_time < 4) { |
166 | toxav_iterate(AliceAV); | 168 | toxav_iterate(AliceAV); |
167 | toxav_iterate(BobAV); | 169 | toxav_iterate(BobAV); |
168 | 170 | ||
169 | toxav_audio_send_frame(AliceAV, friend_number, PCM, 960, 1, 48000, NULL); | 171 | toxav_audio_send_frame(AliceAV, friend_number, PCM, 960, 1, 48000, nullptr); |
170 | toxav_audio_send_frame(BobAV, 0, PCM, 960, 1, 48000, NULL); | 172 | toxav_audio_send_frame(BobAV, 0, PCM, 960, 1, 48000, nullptr); |
171 | 173 | ||
172 | toxav_video_send_frame(AliceAV, friend_number, 800, 600, video_y, video_u, video_v, NULL); | 174 | toxav_video_send_frame(AliceAV, friend_number, 800, 600, video_y, video_u, video_v, nullptr); |
173 | toxav_video_send_frame(BobAV, 0, 800, 600, video_y, video_u, video_v, NULL); | 175 | toxav_video_send_frame(BobAV, 0, 800, 600, video_y, video_u, video_v, nullptr); |
174 | 176 | ||
175 | c_sleep(10); | 177 | c_sleep(10); |
176 | } | 178 | } |
@@ -192,7 +194,7 @@ static void *call_thread(void *pd) | |||
192 | free(video_v); | 194 | free(video_v); |
193 | 195 | ||
194 | printf("Closing thread\n"); | 196 | printf("Closing thread\n"); |
195 | pthread_exit(NULL); | 197 | pthread_exit(nullptr); |
196 | } | 198 | } |
197 | 199 | ||
198 | 200 | ||
@@ -208,25 +210,25 @@ START_TEST(test_AV_three_calls) | |||
208 | { | 210 | { |
209 | TOX_ERR_NEW error; | 211 | TOX_ERR_NEW error; |
210 | 212 | ||
211 | bootstrap = tox_new_log(NULL, &error, &index[0]); | 213 | bootstrap = tox_new_log(nullptr, &error, &index[0]); |
212 | ck_assert(error == TOX_ERR_NEW_OK); | 214 | ck_assert(error == TOX_ERR_NEW_OK); |
213 | 215 | ||
214 | Alice = tox_new_log(NULL, &error, &index[1]); | 216 | Alice = tox_new_log(nullptr, &error, &index[1]); |
215 | ck_assert(error == TOX_ERR_NEW_OK); | 217 | ck_assert(error == TOX_ERR_NEW_OK); |
216 | 218 | ||
217 | Bobs[0] = tox_new_log(NULL, &error, &index[2]); | 219 | Bobs[0] = tox_new_log(nullptr, &error, &index[2]); |
218 | ck_assert(error == TOX_ERR_NEW_OK); | 220 | ck_assert(error == TOX_ERR_NEW_OK); |
219 | 221 | ||
220 | Bobs[1] = tox_new_log(NULL, &error, &index[3]); | 222 | Bobs[1] = tox_new_log(nullptr, &error, &index[3]); |
221 | ck_assert(error == TOX_ERR_NEW_OK); | 223 | ck_assert(error == TOX_ERR_NEW_OK); |
222 | 224 | ||
223 | Bobs[2] = tox_new_log(NULL, &error, &index[4]); | 225 | Bobs[2] = tox_new_log(nullptr, &error, &index[4]); |
224 | ck_assert(error == TOX_ERR_NEW_OK); | 226 | ck_assert(error == TOX_ERR_NEW_OK); |
225 | } | 227 | } |
226 | 228 | ||
227 | printf("Created 5 instances of Tox\n"); | 229 | printf("Created 5 instances of Tox\n"); |
228 | printf("Preparing network...\n"); | 230 | printf("Preparing network...\n"); |
229 | long long unsigned int cur_time = time(NULL); | 231 | long long unsigned int cur_time = time(nullptr); |
230 | 232 | ||
231 | uint8_t address[TOX_ADDRESS_SIZE]; | 233 | uint8_t address[TOX_ADDRESS_SIZE]; |
232 | 234 | ||
@@ -234,34 +236,34 @@ START_TEST(test_AV_three_calls) | |||
234 | tox_self_get_address(Alice, address); | 236 | tox_self_get_address(Alice, address); |
235 | 237 | ||
236 | 238 | ||
237 | ck_assert(tox_friend_add(Bobs[0], address, (const uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); | 239 | ck_assert(tox_friend_add(Bobs[0], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); |
238 | ck_assert(tox_friend_add(Bobs[1], address, (const uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); | 240 | ck_assert(tox_friend_add(Bobs[1], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); |
239 | ck_assert(tox_friend_add(Bobs[2], address, (const uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); | 241 | ck_assert(tox_friend_add(Bobs[2], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); |
240 | 242 | ||
241 | uint8_t off = 1; | 243 | uint8_t off = 1; |
242 | 244 | ||
243 | while (1) { | 245 | while (1) { |
244 | tox_iterate(bootstrap, NULL); | 246 | tox_iterate(bootstrap, nullptr); |
245 | tox_iterate(Alice, NULL); | 247 | tox_iterate(Alice, nullptr); |
246 | tox_iterate(Bobs[0], NULL); | 248 | tox_iterate(Bobs[0], nullptr); |
247 | tox_iterate(Bobs[1], NULL); | 249 | tox_iterate(Bobs[1], nullptr); |
248 | tox_iterate(Bobs[2], NULL); | 250 | tox_iterate(Bobs[2], nullptr); |
249 | 251 | ||
250 | if (tox_self_get_connection_status(bootstrap) && | 252 | if (tox_self_get_connection_status(bootstrap) && |
251 | tox_self_get_connection_status(Alice) && | 253 | tox_self_get_connection_status(Alice) && |
252 | tox_self_get_connection_status(Bobs[0]) && | 254 | tox_self_get_connection_status(Bobs[0]) && |
253 | tox_self_get_connection_status(Bobs[1]) && | 255 | tox_self_get_connection_status(Bobs[1]) && |
254 | tox_self_get_connection_status(Bobs[2]) && off) { | 256 | tox_self_get_connection_status(Bobs[2]) && off) { |
255 | printf("Toxes are online, took %llu seconds\n", time(NULL) - cur_time); | 257 | printf("Toxes are online, took %llu seconds\n", time(nullptr) - cur_time); |
256 | off = 0; | 258 | off = 0; |
257 | } | 259 | } |
258 | 260 | ||
259 | if (tox_friend_get_connection_status(Alice, 0, NULL) == TOX_CONNECTION_UDP && | 261 | if (tox_friend_get_connection_status(Alice, 0, nullptr) == TOX_CONNECTION_UDP && |
260 | tox_friend_get_connection_status(Alice, 1, NULL) == TOX_CONNECTION_UDP && | 262 | tox_friend_get_connection_status(Alice, 1, nullptr) == TOX_CONNECTION_UDP && |
261 | tox_friend_get_connection_status(Alice, 2, NULL) == TOX_CONNECTION_UDP && | 263 | tox_friend_get_connection_status(Alice, 2, nullptr) == TOX_CONNECTION_UDP && |
262 | tox_friend_get_connection_status(Bobs[0], 0, NULL) == TOX_CONNECTION_UDP && | 264 | tox_friend_get_connection_status(Bobs[0], 0, nullptr) == TOX_CONNECTION_UDP && |
263 | tox_friend_get_connection_status(Bobs[1], 0, NULL) == TOX_CONNECTION_UDP && | 265 | tox_friend_get_connection_status(Bobs[1], 0, nullptr) == TOX_CONNECTION_UDP && |
264 | tox_friend_get_connection_status(Bobs[2], 0, NULL) == TOX_CONNECTION_UDP) { | 266 | tox_friend_get_connection_status(Bobs[2], 0, nullptr) == TOX_CONNECTION_UDP) { |
265 | break; | 267 | break; |
266 | } | 268 | } |
267 | 269 | ||
@@ -274,7 +276,7 @@ START_TEST(test_AV_three_calls) | |||
274 | BobsAV[2] = setup_av_instance(Bobs[2], BobsCC + 2); | 276 | BobsAV[2] = setup_av_instance(Bobs[2], BobsCC + 2); |
275 | 277 | ||
276 | printf("Created 4 instances of ToxAV\n"); | 278 | printf("Created 4 instances of ToxAV\n"); |
277 | printf("All set after %llu seconds!\n", time(NULL) - cur_time); | 279 | printf("All set after %llu seconds!\n", time(nullptr) - cur_time); |
278 | 280 | ||
279 | thread_data tds[3]; | 281 | thread_data tds[3]; |
280 | tds[0].AliceAV = AliceAV; | 282 | tds[0].AliceAV = AliceAV; |
@@ -296,28 +298,28 @@ START_TEST(test_AV_three_calls) | |||
296 | tds[2].friend_number = 2; | 298 | tds[2].friend_number = 2; |
297 | 299 | ||
298 | pthread_t tids[3]; | 300 | pthread_t tids[3]; |
299 | (void) pthread_create(tids + 0, NULL, call_thread, tds + 0); | 301 | (void) pthread_create(tids + 0, nullptr, call_thread, tds + 0); |
300 | (void) pthread_create(tids + 1, NULL, call_thread, tds + 1); | 302 | (void) pthread_create(tids + 1, nullptr, call_thread, tds + 1); |
301 | (void) pthread_create(tids + 2, NULL, call_thread, tds + 2); | 303 | (void) pthread_create(tids + 2, nullptr, call_thread, tds + 2); |
302 | 304 | ||
303 | time_t start_time = time(NULL); | 305 | time_t start_time = time(nullptr); |
304 | 306 | ||
305 | while (time(NULL) - start_time < 5) { | 307 | while (time(nullptr) - start_time < 5) { |
306 | tox_iterate(Alice, NULL); | 308 | tox_iterate(Alice, nullptr); |
307 | tox_iterate(Bobs[0], NULL); | 309 | tox_iterate(Bobs[0], nullptr); |
308 | tox_iterate(Bobs[1], NULL); | 310 | tox_iterate(Bobs[1], nullptr); |
309 | tox_iterate(Bobs[2], NULL); | 311 | tox_iterate(Bobs[2], nullptr); |
310 | c_sleep(20); | 312 | c_sleep(20); |
311 | } | 313 | } |
312 | 314 | ||
313 | ck_assert(pthread_join(tids[0], &retval) == 0); | 315 | ck_assert(pthread_join(tids[0], &retval) == 0); |
314 | ck_assert(retval == NULL); | 316 | ck_assert(retval == nullptr); |
315 | 317 | ||
316 | ck_assert(pthread_join(tids[1], &retval) == 0); | 318 | ck_assert(pthread_join(tids[1], &retval) == 0); |
317 | ck_assert(retval == NULL); | 319 | ck_assert(retval == nullptr); |
318 | 320 | ||
319 | ck_assert(pthread_join(tids[2], &retval) == 0); | 321 | ck_assert(pthread_join(tids[2], &retval) == 0); |
320 | ck_assert(retval == NULL); | 322 | ck_assert(retval == nullptr); |
321 | 323 | ||
322 | printf("Killing all instances\n"); | 324 | printf("Killing all instances\n"); |
323 | toxav_kill(BobsAV[0]); | 325 | toxav_kill(BobsAV[0]); |
@@ -355,7 +357,7 @@ int main(int argc, char *argv[]) | |||
355 | Suite *tox = tox_suite(); | 357 | Suite *tox = tox_suite(); |
356 | SRunner *test_runner = srunner_create(tox); | 358 | SRunner *test_runner = srunner_create(tox); |
357 | 359 | ||
358 | setbuf(stdout, NULL); | 360 | setbuf(stdout, nullptr); |
359 | 361 | ||
360 | srunner_run_all(test_runner, CK_NORMAL); | 362 | srunner_run_all(test_runner, CK_NORMAL); |
361 | int number_failed = srunner_ntests_failed(test_runner); | 363 | int number_failed = srunner_ntests_failed(test_runner); |