@@ -34,6 +34,10 @@ TEST_IFX(wifi_extras, wifi_connect_to_ap) {
3434 TEST_ASSERT_EQUAL_INT (WL_CONNECTED, result);
3535}
3636
37+ /* This IP address variable is declared as global
38+ because it will be obtained in client_connect_by_hostname,
39+ and used by check_host_by_name */
40+ IPAddress host_ip;
3741
3842TEST_IFX (wifi_extras, client_connect_by_hostname) {
3943 WiFiClient client;
@@ -48,17 +52,19 @@ TEST_IFX(wifi_extras, client_connect_by_hostname) {
4852 TEST_ASSERT_EQUAL_UINT8 (SOCKET_STATUS_CONNECTED, client.status ());
4953
5054 Serial.print (" Remote IP: " );
51- Serial.print (client.remoteIP ().toString ().c_str ());
55+ host_ip = client.remoteIP ();
56+ Serial.print (host_ip.toString ().c_str ());
5257 TEST_ASSERT_EQUAL_UINT16 (port, client.remotePort ());
5358
5459 client.stop ();
5560}
5661
5762TEST_IFX (wifi_extras, check_host_by_name) {
5863 IPAddress ip;
59- IPAddress ip_expected = IPAddress ( 127 , 0 , 0 , 1 ) ;
64+ IPAddress ip_expected = host_ip ;
6065 /* This domain provides a fix IP for testing */
61- const char *hostname = " localhost" ;
66+ const char *hostname = " google.com" ;
67+
6268
6369 int ret = WiFi.hostByName (hostname, ip);
6470 TEST_ASSERT_TRUE (ret);
@@ -109,10 +115,9 @@ TEST_IFX(wifi_extras, wifi_end) {
109115TEST_GROUP_RUNNER (wifi_extras) {
110116 RUN_TEST_CASE (wifi_extras, wifi_connect_to_ap);
111117 RUN_TEST_CASE (wifi_extras, client_connect_by_hostname);
112- // TODO: This test needs to fixed as the host name is not resolved with expected ip address
113- // RUN_TEST_CASE(wifi_extras, check_host_by_name);
114118 RUN_TEST_CASE (wifi_extras, check_dns);
115119 RUN_TEST_CASE (wifi_extras, check_ping);
120+ RUN_TEST_CASE (wifi_extras, check_host_by_name);
116121 RUN_TEST_CASE (wifi_extras, check_set_dns);
117122 RUN_TEST_CASE (wifi_extras, wifi_disconnect);
118123 RUN_TEST_CASE (wifi_extras, wifi_end);
0 commit comments