Skip to content

DNS tests: improve debug messages #9129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions TESTS/netsocket/dns/asynchronous_dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void ASYNCHRONOUS_DNS()
{
do_asynchronous_gethostbyname(dns_test_hosts, 1, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == 1);
TEST_ASSERT(result_no_mem == 0);
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(1, result_ok);
TEST_ASSERT_EQUAL(0, result_no_mem);
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}
2 changes: 1 addition & 1 deletion TESTS/netsocket/dns/asynchronous_dns_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void ASYNCHRONOUS_DNS_CACHE()

semaphore.wait();

TEST_ASSERT(data.result == NSAPI_ERROR_OK);
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, data.result);
TEST_ASSERT(strlen(data.addr.get_ip_address()) > 1);

int delay_ms = (ticker_us - started_us) / 1000;
Expand Down
16 changes: 8 additions & 8 deletions TESTS/netsocket/dns/asynchronous_dns_external_event_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE()
do_asynchronous_gethostbyname(dns_test_hosts, MBED_CONF_NSAPI_DNS_CACHE_SIZE, &result_ok, &result_no_mem,
&result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == MBED_CONF_NSAPI_DNS_CACHE_SIZE);
TEST_ASSERT(result_no_mem == 0);
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(MBED_CONF_NSAPI_DNS_CACHE_SIZE, result_ok);
TEST_ASSERT_EQUAL(0, result_no_mem);
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);

// Dispatch event queue
Thread eventThread(osPriorityNormal, EXTERNAL_THREAD_SIZE);
Expand All @@ -73,10 +73,10 @@ void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE()
do_asynchronous_gethostbyname(dns_test_hosts_second, MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, &result_ok, &result_no_mem,
&result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES);
TEST_ASSERT(result_no_mem == 1); // last query fails for no memory as expected
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(MBED_CONF_APP_DNS_SIMULT_QUERIES, result_ok);
TEST_ASSERT_EQUAL(1, result_no_mem); // last query fails for no memory as expected
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);

// Give event queue time to finalise before destructors
wait(2.0);
Expand Down
6 changes: 3 additions & 3 deletions TESTS/netsocket/dns/asynchronous_dns_invalid_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void ASYNCHRONOUS_DNS_INVALID_HOST()
do_asynchronous_gethostbyname(dns_test_hosts_new, MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, &result_ok, &result_no_mem,
&result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == exp_ok);
TEST_ASSERT(result_no_mem == 1); // last query fails for no memory as expected
TEST_ASSERT_EQUAL(exp_ok, result_ok);
TEST_ASSERT_EQUAL(1, result_no_mem); // last query fails for no memory as expected
TEST_ASSERT(result_dns_failure == exp_dns_failure || result_dns_failure == exp_dns_failure + 1);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()

semaphore.wait(100);

TEST_ASSERT(data.result == NSAPI_ERROR_OK);
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, data.result);

printf("DNS: query \"%s\" => \"%s\"\n",
dns_test_hosts_second[0], data.addr.get_ip_address());
Expand Down
8 changes: 4 additions & 4 deletions TESTS/netsocket/dns/asynchronous_dns_simultaneous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ void ASYNCHRONOUS_DNS_SIMULTANEOUS()
do_asynchronous_gethostbyname(dns_test_hosts_second, MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, &result_ok, &result_no_mem,
&result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES);
TEST_ASSERT(result_no_mem == 1); // last query fails for no memory as expected
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(MBED_CONF_APP_DNS_SIMULT_QUERIES, result_ok);
TEST_ASSERT_EQUAL(1, result_no_mem); // last query fails for no memory as expected
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}
8 changes: 4 additions & 4 deletions TESTS/netsocket/dns/asynchronous_dns_simultaneous_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void ASYNCHRONOUS_DNS_SIMULTANEOUS_CACHE()
&result_dns_failure, &result_exp_timeout);

// Addresses were cached on last step, OK for all
TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES + 1);
TEST_ASSERT(result_no_mem == 0);
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, result_ok);
TEST_ASSERT_EQUAL(0, result_no_mem);
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}
4 changes: 2 additions & 2 deletions TESTS/netsocket/dns/asynchronous_dns_simultaneous_repeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT()
// For 1st round can fail to no memory, on other rounds some of the addresses are found from cache
TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES || result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES + 1);
TEST_ASSERT(result_no_mem == 1 || result_no_mem == 0); // last query fails for 1st round to no memory as expected
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}
}
8 changes: 4 additions & 4 deletions TESTS/netsocket/dns/asynchronous_dns_timeouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ void ASYNCHRONOUS_DNS_TIMEOUTS()
do_asynchronous_gethostbyname(dns_test_hosts, MBED_CONF_NSAPI_DNS_CACHE_SIZE, &result_ok, &result_no_mem,
&result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == MBED_CONF_NSAPI_DNS_CACHE_SIZE);
TEST_ASSERT(result_no_mem == 0);
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(MBED_CONF_NSAPI_DNS_CACHE_SIZE, result_ok);
TEST_ASSERT_EQUAL(0, result_no_mem);
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);

// Dispatch event queue
Thread eventThread(osPriorityNormal, EXTERNAL_THREAD_SIZE);
Expand Down
4 changes: 3 additions & 1 deletion TESTS/netsocket/dns/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ void do_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsigned int op_cou
SocketAddress address;
nsapi_error_t err = net->gethostbyname(hosts[i], &address);

TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_NO_MEMORY || err == NSAPI_ERROR_DNS_FAILURE || err == NSAPI_ERROR_TIMEOUT);
if (err == NSAPI_ERROR_OK) {
(*exp_ok)++;
printf("DNS: query \"%s\" => \"%s\"\n",
Expand All @@ -136,6 +135,9 @@ void do_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsigned int op_cou
} else if (err == NSAPI_ERROR_NO_MEMORY) {
(*exp_no_mem)++;
printf("DNS: query \"%s\" => no memory\n", hosts[i]);
} else {
printf("DNS: query \"%s\" => %d, unexpected answer\n", hosts[i], err);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_NO_MEMORY || err == NSAPI_ERROR_DNS_FAILURE || err == NSAPI_ERROR_TIMEOUT);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions TESTS/netsocket/dns/synchronous_dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void SYNCHRONOUS_DNS()
{
do_gethostbyname(dns_test_hosts, 1, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == 1);
TEST_ASSERT(result_no_mem == 0);
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(1, result_ok);
TEST_ASSERT_EQUAL(0, result_no_mem);
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}
8 changes: 4 additions & 4 deletions TESTS/netsocket/dns/synchronous_dns_invalid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ void SYNCHRONOUS_DNS_INVALID()

do_gethostbyname(dns_test_hosts_new, MBED_CONF_APP_DNS_TEST_HOSTS_NUM, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == expected_successes);
TEST_ASSERT(result_no_mem == 0);
TEST_ASSERT(result_dns_failure == expected_failures);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(expected_successes, result_ok);
TEST_ASSERT_EQUAL(0, result_no_mem);
TEST_ASSERT_EQUAL(expected_failures, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}
8 changes: 4 additions & 4 deletions TESTS/netsocket/dns/synchronous_dns_multiple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void SYNCHRONOUS_DNS_MULTIPLE()
{
do_gethostbyname(dns_test_hosts, MBED_CONF_APP_DNS_TEST_HOSTS_NUM, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);

TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_TEST_HOSTS_NUM);
TEST_ASSERT(result_no_mem == 0);
TEST_ASSERT(result_dns_failure == 0);
TEST_ASSERT(result_exp_timeout == 0);
TEST_ASSERT_EQUAL(MBED_CONF_APP_DNS_TEST_HOSTS_NUM, result_ok);
TEST_ASSERT_EQUAL(0, result_no_mem);
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}