DNS tests: Cancel asynchronous dns query if it times out

In this test case if asynchronous DNS request results does not happen
in requested time, the request must be cancelled to ensure it does not
happen later on when test has exited already.

We've seen couple of crashes in CI tests which indicate this kind of behaviour
but this is very difficult to reproduce.
pull/11936/head
Kimmo Vaisanen 2019-11-25 10:01:09 +02:00
parent 1a2ecebc62
commit 896bc4432b
1 changed files with 4 additions and 1 deletions

View File

@ -30,6 +30,7 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
rtos::Semaphore semaphore;
dns_application_data data;
data.semaphore = &semaphore;
data.result = NSAPI_ERROR_TIMEOUT;
nsapi_dns_reset();
@ -49,7 +50,9 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
TEST_ASSERT(strlen(addr.get_ip_address()) > 1);
}
semaphore.try_acquire_for(100);
if (!semaphore.try_acquire_for(1000)) {
get_interface()->gethostbyname_async_cancel(err);
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, data.result);