@@ -107,6 +107,39 @@ void do_asynchronous_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsign
107
107
delete[] data;
108
108
}
109
109
110
+ void do_gethostbyname (const char hosts[][DNS_TEST_HOST_LEN], unsigned int op_count, int *exp_ok, int *exp_no_mem, int *exp_dns_failure, int *exp_timeout)
111
+ {
112
+ // Verify that there is enough hosts in the host list
113
+ TEST_ASSERT (op_count <= MBED_CONF_APP_DNS_TEST_HOSTS_NUM)
114
+
115
+ // Reset counters
116
+ (*exp_ok) = 0 ;
117
+ (*exp_no_mem) = 0 ;
118
+ (*exp_dns_failure) = 0 ;
119
+ (*exp_timeout) = 0 ;
120
+
121
+ for (unsigned int i = 0 ; i < op_count; i++) {
122
+ SocketAddress address;
123
+ nsapi_error_t err = net->gethostbyname (hosts[i], &address);
124
+
125
+ TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_NO_MEMORY || err == NSAPI_ERROR_DNS_FAILURE || err == NSAPI_ERROR_TIMEOUT);
126
+ if (err == NSAPI_ERROR_OK) {
127
+ (*exp_ok)++;
128
+ printf (" DNS: query \" %s\" => \" %s\"\n " ,
129
+ hosts[i], address.get_ip_address ());
130
+ } else if (err == NSAPI_ERROR_DNS_FAILURE) {
131
+ (*exp_dns_failure)++;
132
+ printf (" DNS: query \" %s\" => DNS failure\n " , hosts[i]);
133
+ } else if (err == NSAPI_ERROR_TIMEOUT) {
134
+ (*exp_timeout)++;
135
+ printf (" DNS: query \" %s\" => timeout\n " , hosts[i]);
136
+ } else if (err == NSAPI_ERROR_NO_MEMORY) {
137
+ (*exp_no_mem)++;
138
+ printf (" DNS: query \" %s\" => no memory\n " , hosts[i]);
139
+ }
140
+ }
141
+ }
142
+
110
143
NetworkInterface *get_interface ()
111
144
{
112
145
return net;
@@ -145,6 +178,10 @@ Case cases[] = {
145
178
#ifdef MBED_EXTENDED_TESTS
146
179
Case (" ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT" , ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT),
147
180
#endif
181
+ Case (" SYNCHRONOUS_DNS" , SYNCHRONOUS_DNS),
182
+ Case (" SYNCHRONOUS_DNS_MULTIPLE" , SYNCHRONOUS_DNS_MULTIPLE),
183
+ Case (" SYNCHRONOUS_DNS_CACHE" , SYNCHRONOUS_DNS_CACHE),
184
+ Case (" SYNCHRONOUS_DNS_INVALID" , SYNCHRONOUS_DNS_INVALID),
148
185
};
149
186
150
187
Specification specification (test_setup, cases);
0 commit comments