mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
1a2ecebc62
commit
896bc4432b
|
@ -30,6 +30,7 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
|
||||||
rtos::Semaphore semaphore;
|
rtos::Semaphore semaphore;
|
||||||
dns_application_data data;
|
dns_application_data data;
|
||||||
data.semaphore = &semaphore;
|
data.semaphore = &semaphore;
|
||||||
|
data.result = NSAPI_ERROR_TIMEOUT;
|
||||||
|
|
||||||
nsapi_dns_reset();
|
nsapi_dns_reset();
|
||||||
|
|
||||||
|
@ -49,7 +50,9 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
|
||||||
TEST_ASSERT(strlen(addr.get_ip_address()) > 1);
|
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);
|
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, data.result);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue