mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Increase range of ports available to Toxes during tests
This commit is contained in:
parent
9d58e0aa0a
commit
ec8b911d7c
|
@ -202,22 +202,6 @@ START_TEST(test_few_clients)
|
|||
|
||||
ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");
|
||||
|
||||
{
|
||||
TOX_ERR_GET_PORT error;
|
||||
uint16_t first_port = tox_self_get_udp_port(tox1, &error);
|
||||
ck_assert_msg(33445 <= first_port && first_port <= 33545 - 2,
|
||||
"First Tox instance did not bind to udp port inside [33445, 33543].\n");
|
||||
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
|
||||
|
||||
ck_assert_msg(tox_self_get_udp_port(tox2, &error) == first_port + 1,
|
||||
"Second Tox instance did not bind to udp port %d.\n", first_port + 1);
|
||||
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
|
||||
|
||||
ck_assert_msg(tox_self_get_udp_port(tox3, &error) == first_port + 2,
|
||||
"Third Tox instance did not bind to udp port %d.\n", first_port + 2);
|
||||
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
|
||||
}
|
||||
|
||||
tox_callback_friend_request(tox2, accept_friend_request);
|
||||
uint8_t address[TOX_ADDRESS_SIZE];
|
||||
tox_self_get_address(tox2, address);
|
||||
|
|
|
@ -65,6 +65,8 @@ Tox *tox_new_log_lan(struct Tox_Options *options, TOX_ERR_NEW *err, void *log_us
|
|||
assert(log_options != nullptr);
|
||||
|
||||
tox_options_set_local_discovery_enabled(log_options, lan_discovery);
|
||||
tox_options_set_start_port(log_options, 33445);
|
||||
tox_options_set_end_port(log_options, 33445 + 2000);
|
||||
tox_options_set_log_callback(log_options, &print_debug_log);
|
||||
tox_options_set_log_user_data(log_options, log_user_data);
|
||||
Tox *tox = tox_new(log_options, err);
|
||||
|
|
|
@ -38,17 +38,26 @@ int main(void)
|
|||
#endif
|
||||
printf("Creating/deleting %d tox instances\n", ITERATIONS);
|
||||
|
||||
int allocated = 0;
|
||||
|
||||
for (int i = 0; i < ITERATIONS; i++) {
|
||||
Tox *tox = tox_new(nullptr, nullptr);
|
||||
tox_iterate(tox, nullptr);
|
||||
tox_kill(tox);
|
||||
|
||||
if (tox != nullptr) {
|
||||
tox_iterate(tox, nullptr);
|
||||
tox_kill(tox);
|
||||
allocated++;
|
||||
}
|
||||
|
||||
#if HAVE_SBRK
|
||||
char *next_hwm = (char *)sbrk(0);
|
||||
assert(hwm == next_hwm);
|
||||
#endif
|
||||
}
|
||||
|
||||
puts("Success: no resource leaks detected");
|
||||
assert(allocated >= ITERATIONS / 2);
|
||||
printf("Success: no resource leaks detected in %d tox_new calls (tried %d)\n",
|
||||
allocated, ITERATIONS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -75,17 +75,6 @@ START_TEST(test_many_clients_tcp)
|
|||
tox_options_free(opts);
|
||||
}
|
||||
|
||||
{
|
||||
TOX_ERR_GET_PORT error;
|
||||
uint16_t port = tox_self_get_udp_port(toxes[0], &error);
|
||||
ck_assert_msg(33445 <= port && port <= 33545,
|
||||
"First Tox instance did not bind to udp port inside [33445, 33545].\n");
|
||||
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
|
||||
ck_assert_msg(tox_self_get_tcp_port(toxes[0], &error) == TCP_RELAY_PORT,
|
||||
"First Tox instance did not bind to tcp port %u.\n", TCP_RELAY_PORT);
|
||||
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
|
||||
}
|
||||
|
||||
struct {
|
||||
uint16_t tox1;
|
||||
uint16_t tox2;
|
||||
|
@ -180,17 +169,6 @@ START_TEST(test_many_clients_tcp_b)
|
|||
tox_options_free(opts);
|
||||
}
|
||||
|
||||
{
|
||||
TOX_ERR_GET_PORT error;
|
||||
uint16_t port = tox_self_get_udp_port(toxes[0], &error);
|
||||
ck_assert_msg(33445 <= port && port <= 33545,
|
||||
"First Tox instance did not bind to udp port inside [33445, 33545].\n");
|
||||
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
|
||||
ck_assert_msg(tox_self_get_tcp_port(toxes[0], &error) == TCP_RELAY_PORT,
|
||||
"First Tox instance did not bind to tcp port %u.\n", TCP_RELAY_PORT);
|
||||
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
|
||||
}
|
||||
|
||||
struct {
|
||||
uint16_t tox1;
|
||||
uint16_t tox2;
|
||||
|
|
|
@ -125,14 +125,6 @@ START_TEST(test_one)
|
|||
tox_self_get_public_key(tox2, pk);
|
||||
ck_assert_msg(memcmp(pk, address, TOX_PUBLIC_KEY_SIZE) == 0, "Wrong public key.");
|
||||
|
||||
{
|
||||
TOX_ERR_GET_PORT error;
|
||||
uint16_t port = tox_self_get_udp_port(tox1, &error);
|
||||
ck_assert_msg(33445 <= port && port <= 33545,
|
||||
"First Tox instance did not bind to udp port inside [33445, 33545].\n");
|
||||
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
|
||||
}
|
||||
|
||||
tox_options_free(options);
|
||||
tox_kill(tox1);
|
||||
tox_kill(tox2);
|
||||
|
|
Loading…
Reference in New Issue
Block a user