Skip to content

Commit 860f18b

Browse files
authored
Merge pull request #11819 from tymoteuszblochmobica/timeouts
Add code to verify if external Wifi module is still responsible
2 parents 7fbe0c6 + 678b57c commit 860f18b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

TESTS/netsocket/dns/asynchronous_dns_timeouts.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int result_exp_timeout;
3333

3434
const int EXTERNAL_THREAD_SIZE = 2048;
3535
const int EVENT_QUEUE_SIZE = 10;
36+
const int MAX_TRIAL_ATTEMPTS = 15;
3637

3738
events::EventQueue *event_queue;
3839
}
@@ -66,9 +67,22 @@ void ASYNCHRONOUS_DNS_TIMEOUTS()
6667
// Depends on timing, but at least one operation shall fail to timeout
6768
TEST_ASSERT(result_exp_timeout > 0);
6869

69-
// Give event queue time to finalise before destructors
70-
ThisThread::sleep_for(12000);
71-
7270
nsapi_dns_call_in_set(0);
71+
72+
nsapi_dns_reset();
73+
SocketAddress address;
74+
nsapi_error_t result;
75+
int count = MAX_TRIAL_ATTEMPTS;
76+
do {
77+
result = NetworkInterface::get_default_instance()->gethostbyname(dns_test_hosts[0], &address);
78+
if (result == NSAPI_ERROR_OK) {
79+
return;
80+
}
81+
ThisThread::sleep_for(1000);
82+
count--;
83+
} while (result != NSAPI_ERROR_OK && count);
84+
85+
7386
}
7487
#endif // defined(MBED_CONF_RTOS_PRESENT)
88+

0 commit comments

Comments
 (0)