Skip to content

Commit 678b57c

Browse files
Add code to verify if external Wifi module is still responsible
after DNS Query flooding during DNS timeout test. DNS timeout test requires flooding device with DNS queries. This causes problem to ESP8266 module causing it to stuck for 11 sec. In result all following tests fails. To avoid this "smart delay" is added. If device preforms gethostbyname correctly then tests can proceed. Otherwise after 1 sec sleep gethostbyname is repeated until success or re-check limit (set to 15). Thanks to this all ethernet and non ESP8266 wireless devices don't need to wait but ESP must wait.
1 parent 609612c commit 678b57c

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)