Fix assert for the first port value

Port of the first tox instance will be 33445 only if this port was not
in use during testing
This commit is contained in:
Diadlo 2017-08-25 09:30:40 +03:00
parent 2651193b99
commit c506d73d5d
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
5 changed files with 22 additions and 14 deletions

View File

@ -106,7 +106,9 @@ group_test_restart:
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
const 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");
}

View File

@ -74,7 +74,9 @@ START_TEST(test_many_clients_tcp)
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
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);
@ -176,7 +178,9 @@ START_TEST(test_many_clients_tcp_b)
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
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);

View File

@ -50,7 +50,9 @@ START_TEST(test_many_clients)
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
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");
}

View File

@ -127,7 +127,9 @@ START_TEST(test_one)
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
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");
}

View File

@ -331,19 +331,17 @@ START_TEST(test_few_clients)
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
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");
}
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(tox2, &error) == 33446, "Second Tox instance did not bind to udp port 33446.\n");
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");
}
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(tox3, &error) == 33447, "Third Tox instance did not bind to udp port 33447.\n");
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");
}