Skip to content

Commit 502daa9

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 9c82706 commit 502daa9

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
@@ -31,6 +31,7 @@ int result_exp_timeout;
3131

3232
const int EXTERNAL_THREAD_SIZE = 2048;
3333
const int EVENT_QUEUE_SIZE = 10;
34+
const int MAX_TRIAL_ATTEMPTS = 15;
3435

3536
events::EventQueue *event_queue;
3637
}
@@ -64,8 +65,21 @@ void ASYNCHRONOUS_DNS_TIMEOUTS()
6465
// Depends on timing, but at least one operation shall fail to timeout
6566
TEST_ASSERT(result_exp_timeout > 0);
6667

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

0 commit comments

Comments
 (0)