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.
pull/11819/head
Tymoteusz Bloch 2019-10-28 13:51:18 +01:00
parent 609612c1f2
commit 678b57c253
1 changed files with 17 additions and 3 deletions

View File

@ -33,6 +33,7 @@ int result_exp_timeout;
const int EXTERNAL_THREAD_SIZE = 2048;
const int EVENT_QUEUE_SIZE = 10;
const int MAX_TRIAL_ATTEMPTS = 15;
events::EventQueue *event_queue;
}
@ -66,9 +67,22 @@ void ASYNCHRONOUS_DNS_TIMEOUTS()
// Depends on timing, but at least one operation shall fail to timeout
TEST_ASSERT(result_exp_timeout > 0);
// Give event queue time to finalise before destructors
ThisThread::sleep_for(12000);
nsapi_dns_call_in_set(0);
nsapi_dns_reset();
SocketAddress address;
nsapi_error_t result;
int count = MAX_TRIAL_ATTEMPTS;
do {
result = NetworkInterface::get_default_instance()->gethostbyname(dns_test_hosts[0], &address);
if (result == NSAPI_ERROR_OK) {
return;
}
ThisThread::sleep_for(1000);
count--;
} while (result != NSAPI_ERROR_OK && count);
}
#endif // defined(MBED_CONF_RTOS_PRESENT)