Skip to content

Commit 896bc44

Browse files
author
Kimmo Vaisanen
committed
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.
1 parent 1a2eceb commit 896bc44

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

TESTS/netsocket/dns/asynchronous_dns_non_async_and_async.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
3030
rtos::Semaphore semaphore;
3131
dns_application_data data;
3232
data.semaphore = &semaphore;
33+
data.result = NSAPI_ERROR_TIMEOUT;
3334

3435
nsapi_dns_reset();
3536

@@ -49,7 +50,9 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
4950
TEST_ASSERT(strlen(addr.get_ip_address()) > 1);
5051
}
5152

52-
semaphore.try_acquire_for(100);
53+
if (!semaphore.try_acquire_for(1000)) {
54+
get_interface()->gethostbyname_async_cancel(err);
55+
}
5356

5457
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, data.result);
5558

0 commit comments

Comments
 (0)