2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for DnsQuery_A
5 * PROGRAMMER: Victor Martinez Calvo <victor.martinez@reactos.org>
16 void TestHostName(void)
19 DNS_STATUS dns_status
;
23 WCHAR host_nameW
[255];
24 WCHAR test_nameW
[255];
25 PFIXED_INFO network_info
;
26 ULONG network_info_blen
= 0;
27 DWORD network_info_result
;
29 network_info_result
= GetNetworkParams(NULL
, &network_info_blen
);
30 network_info
= (PFIXED_INFO
)HeapAlloc(GetProcessHeap(), 0, (size_t)network_info_blen
);
31 if (NULL
== network_info
)
33 skip("Not enough memory. Can't continue!\n");
37 network_info_result
= GetNetworkParams(network_info
, &network_info_blen
);
38 if (network_info_result
!= ERROR_SUCCESS
)
40 HeapFree(GetProcessHeap(), 0, network_info
);
41 skip("Can't get network info. Some results may be wrong.\n");
46 strcpy(host_name
, network_info
->HostName
);
47 if (strlen(network_info
->DomainName
))
49 strcat(host_name
, ".");
50 strcat(host_name
, network_info
->DomainName
);
52 HeapFree(GetProcessHeap(), 0, network_info
);
53 mbstowcs(host_nameW
, host_name
, 255);
59 dns_status
= DnsQuery_A(NULL
, DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
60 ok(dns_status
== ERROR_INVALID_PARAMETER
, "DnsQuery_A failed with error %lu\n", dns_status
);
61 ok(dp
== InvalidPointer
, "dp = %p\n", dp
);
64 dns_status
= DnsQuery_A(host_name
, DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, NULL
, 0);
65 ok(dns_status
== ERROR_INVALID_PARAMETER
, "DnsQuery_A failed with error %lu\n", dns_status
);
69 dns_status
= DnsQuery_A(host_name
, DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
70 ok(dns_status
== NO_ERROR
, "DnsQuery_A failed with error %lu\n", dns_status
);
71 if (dp
!= InvalidPointer
)
73 ok(strcmp(dp
->pName
, host_name
) == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, host_name
);
74 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
75 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
77 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
78 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
82 dns_status
= DnsQuery_A("127.0.0.1", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
83 ok(dns_status
== NO_ERROR
, "DnsQuery_A failed with error %lu\n", dns_status
);
84 if (dp
!= InvalidPointer
)
86 ok(strcmp(dp
->pName
, "127.0.0.1") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "127.0.0.1");
87 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
88 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
89 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
91 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
92 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
96 dns_status
= DnsQuery_A("LocalHost", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
97 ok(dns_status
== NO_ERROR
, "DnsQuery_A failed with error %lu\n", dns_status
);
98 if (dp
!= InvalidPointer
)
100 /* On Windows 7 is unchanged on XP is lowercased */
101 ok(strcmp(dp
->pName
, "localhost") == 0 || broken(strcmp(dp
->pName
, "LocalHost") == 0), "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "localhost");
102 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
103 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
104 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
106 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
107 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
110 dns_status
= DnsQuery_A("Localhost", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
111 ok(dns_status
== NO_ERROR
, "DnsQuery_A failed with error %lu\n", dns_status
);
112 if (dp
!= InvalidPointer
)
114 /* On Windows 7 is unchanged on XP is lowercased */
115 ok(strcmp(dp
->pName
, "localhost") == 0 || broken(strcmp(dp
->pName
, "Localhost") == 0), "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "localhost");
116 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
117 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
118 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
120 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
121 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
124 dns_status
= DnsQuery_A("localhost", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
125 ok(dns_status
== NO_ERROR
, "DnsQuery_A failed with error %lu\n", dns_status
);
126 if (dp
!= InvalidPointer
)
128 ok(strcmp(dp
->pName
, "localhost") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "localhost");
129 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
130 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
131 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
133 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
134 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
137 dns_status
= DnsQuery_A("", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
138 ok(dns_status
== NO_ERROR
, "DnsQuery_A failed with error %lu\n", dns_status
);
139 if (dp
!= InvalidPointer
)
141 /* On Windows 7 is the host on XP is dot ??? */
142 ok(strcmp(dp
->pName
, ".") == 0 || broken(strcmp(dp
->pName
, host_name
) == 0), "DnsQuery_A returned wrong answer '%s' expected '%s' or '.'\n", dp
->pName
, host_name
);
143 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
144 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
146 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
147 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
150 dns_status
= DnsQuery_A(" ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
151 /* On Windows 7 is DNS_ERROR_INVALID_NAME_CHAR on XP is ERROR_TIMEOUT on Win 2k3 is ERROR_INVALID_NAME*/
152 ok(dns_status
== ERROR_INVALID_NAME
|| broken(dns_status
== ERROR_TIMEOUT
) || broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_A failed with error %lu expected %u or %u or %u\n", dns_status
, ERROR_INVALID_NAME
, ERROR_TIMEOUT
, DNS_ERROR_INVALID_NAME_CHAR
);
153 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
155 ok(strcmp(dp
->pName
, host_name
) == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, host_name
);
156 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
157 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
159 ok(dp
== InvalidPointer
|| broken(dp
== NULL
), "dp = %p\n", dp
);
160 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
163 dns_status
= DnsQuery_A("0.0.0.0", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
164 ok(dns_status
== NO_ERROR
, "DnsQuery_A failed with error %lu\n", dns_status
);
165 if (dp
!= InvalidPointer
)
167 ok(strcmp(dp
->pName
, "0.0.0.0") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "0.0.0.0");
168 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
169 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
170 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_ANY
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_ANY
));
172 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
173 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
176 dns_status
= DnsQuery_A("0.0.0.0 ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
177 /* On windows 7 fails with DNS_ERROR_INVALID_NAME_CHAR on XP no error */
178 ok(dns_status
== NO_ERROR
|| broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_A wrong status %lu expected %u or %u\n", dns_status
, NO_ERROR
, DNS_ERROR_INVALID_NAME_CHAR
);
179 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
181 ok(strcmp(dp
->pName
, "0.0.0.0") == 0 || broken(strcmp(dp
->pName
, "0.0.0.0 ") == 0), "DnsQuery_A returned wrong answer '%s' expected '%s' or '%s'\n", dp
->pName
, "0.0.0.0", "0.0.0.0 ");
182 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
183 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
184 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_ANY
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_ANY
));
186 ok(dp
!= InvalidPointer
|| broken(dp
== InvalidPointer
) || broken(dp
== NULL
), "dp = %p\n", dp
);
187 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
190 dns_status
= DnsQuery_A("127.0.0.1 ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
191 /* On windows 7 fails with DNS_ERROR_INVALID_NAME_CHAR on XP no error */
192 ok(dns_status
== NO_ERROR
|| broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_A wrong status %lu expected %u or %u\n", dns_status
, NO_ERROR
, DNS_ERROR_INVALID_NAME_CHAR
);
193 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
195 ok(strcmp(dp
->pName
, "127.0.0.1") == 0 || strcmp(dp
->pName
, "127.0.0.1 ") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s' or '%s'\n", dp
->pName
, "127.0.0.1", "127.0.0.1 ");
196 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
197 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
198 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
200 ok(dp
!= InvalidPointer
|| broken(dp
== InvalidPointer
) || broken(dp
== NULL
), "dp = %p\n", dp
);
201 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
204 dns_status
= DnsQuery_A(" 127.0.0.1 ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
205 ok(dns_status
== DNS_ERROR_RCODE_NAME_ERROR
|| broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_A wrong status %lu expected %u or %u\n", dns_status
, DNS_ERROR_RCODE_NAME_ERROR
, DNS_ERROR_INVALID_NAME_CHAR
);
206 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
208 ok(strcmp(dp
->pName
, "127.0.0.1") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "127.0.0.1");
209 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
210 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
211 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
213 ok(dp
== InvalidPointer
|| broken(dp
== NULL
), "dp = %p\n", dp
);
214 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
217 dns_status
= DnsQuery_A(" 127.0. 0.1 ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
218 ok(dns_status
== DNS_ERROR_RCODE_NAME_ERROR
|| broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_A wrong status %lu expected %u or %u\n", dns_status
, DNS_ERROR_RCODE_NAME_ERROR
, DNS_ERROR_INVALID_NAME_CHAR
);
219 if (dp
== InvalidPointer
&& dns_status
== NO_ERROR
)
221 ok(strcmp(dp
->pName
, "127.0.0.1") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "127.0.0.1");
222 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
223 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
224 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
226 ok(dp
== InvalidPointer
|| broken(dp
== NULL
), "dp = %p\n", dp
);
227 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
230 dns_status
= DnsQuery_A("localhost ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
231 ok(dns_status
== ERROR_INVALID_NAME
|| broken(dns_status
== ERROR_TIMEOUT
) || broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_A wrong status %lu expected %u or %u or %u\n", dns_status
, ERROR_INVALID_NAME
, ERROR_TIMEOUT
, DNS_ERROR_INVALID_NAME_CHAR
);
232 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
234 ok(strcmp(dp
->pName
, "localhost") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "localhost");
235 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
236 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
237 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
239 ok(dp
== InvalidPointer
|| broken(dp
== NULL
), "dp = %p\n", dp
);
240 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
243 dns_status
= DnsQuery_A(" localhost", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
244 ok(dns_status
== ERROR_INVALID_NAME
|| broken(dns_status
== ERROR_TIMEOUT
) || broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_A wrong status %lu expected %u or %u or %u\n", dns_status
, ERROR_INVALID_NAME
, ERROR_TIMEOUT
, DNS_ERROR_INVALID_NAME_CHAR
);
245 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
247 ok(strcmp(dp
->pName
, "localhost") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "localhost");
248 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
249 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
250 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
252 ok(dp
== InvalidPointer
|| broken(dp
== NULL
), "dp = %p\n", dp
);
253 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
256 strcpy(test_name
, " local host ");
257 dns_status
= DnsQuery_A(test_name
, DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
258 ok(dns_status
== ERROR_INVALID_NAME
|| broken(dns_status
== ERROR_TIMEOUT
) || broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_A wrong status %lu expected %u or %u or %u\n", dns_status
, ERROR_INVALID_NAME
, ERROR_TIMEOUT
, DNS_ERROR_INVALID_NAME_CHAR
);
259 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
261 ok(strcmp(dp
->pName
, "localhost") == 0, "DnsQuery_A returned wrong answer '%s' expected '%s'\n", dp
->pName
, "localhost");
262 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_A returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
263 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_A returned wrong data size %d\n", dp
->wDataLength
);
264 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_A returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
266 ok(dp
== InvalidPointer
|| broken(dp
== NULL
), "dp = %p\n", dp
);
267 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
272 dns_status
= DnsQuery_W(NULL
, DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
273 if (dns_status
== NO_ERROR
)
276 ok(dns_status
== NO_ERROR
, "DnsQuery_W failed with error %lu\n", dns_status
);
277 ok(dp
!= NULL
&& dp
!= InvalidPointer
, "dp = %p\n", dp
);
282 ok(dns_status
== ERROR_INVALID_PARAMETER
, "DnsQuery_W failed with error %lu\n", dns_status
);
283 ok(dp
== InvalidPointer
, "dp = %p\n", dp
);
285 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
288 dns_status
= DnsQuery_W(host_nameW
, DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, NULL
, 0);
289 ok(dns_status
== ERROR_INVALID_PARAMETER
, "DnsQuery_W failed with error %lu\n", dns_status
);
292 dns_status
= DnsQuery_W(host_nameW
, DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
293 ok(dns_status
== NO_ERROR
, "DnsQuery_W failed with error %lu\n", dns_status
);
294 if (dp
!= InvalidPointer
)
296 ok(wcscmp((LPCWSTR
)dp
->pName
, host_nameW
) == 0, "DnsQuery_w returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, host_nameW
);
297 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
298 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_w returned wrong data size %d\n", dp
->wDataLength
);
300 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
301 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
304 dns_status
= DnsQuery_W(L
"127.0.0.1", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
305 ok(dns_status
== NO_ERROR
, "DnsQuery_W failed with error %lu\n", dns_status
);
306 if (dp
!= InvalidPointer
)
308 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"127.0.0.1") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"127.0.0.1");
309 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
310 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
311 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
313 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
314 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
317 dns_status
= DnsQuery_W(L
"LocalHost", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
318 ok(dns_status
== NO_ERROR
, "DnsQuery_W failed with error %lu\n", dns_status
);
319 if (dp
!= InvalidPointer
)
321 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0 || broken(wcscmp((LPCWSTR
)dp
->pName
, L
"LocalHost") == 0), "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
322 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
323 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
324 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
326 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
327 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
329 dns_status
= DnsQuery_W(L
"Localhost", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
330 ok(dns_status
== NO_ERROR
, "DnsQuery_W failed with error %lu\n", dns_status
);
331 if (dp
!= InvalidPointer
)
333 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0 || broken(wcscmp((LPCWSTR
)dp
->pName
, L
"Localhost") == 0), "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
334 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
335 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
336 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
338 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
339 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
341 dns_status
= DnsQuery_W(L
"localhost", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
342 ok(dns_status
== NO_ERROR
, "DnsQuery_W failed with error %lu\n", dns_status
);
343 if (dp
!= InvalidPointer
)
345 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
346 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
347 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
348 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
350 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
351 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
353 dns_status
= DnsQuery_W(L
"", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
354 ok(dns_status
== NO_ERROR
, "DnsQuery_W failed with error %lu\n", dns_status
);
355 if (dp
!= InvalidPointer
)
357 /* On Windows 7 is the host on XP is dot ??? */
358 ok(wcscmp((LPCWSTR
)dp
->pName
, L
".") == 0 || broken(wcscmp((LPCWSTR
)dp
->pName
, host_nameW
) == 0), "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, host_nameW
);
359 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
360 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
362 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
363 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
366 dns_status
= DnsQuery_W(L
" ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
367 ok(dns_status
== ERROR_INVALID_NAME
|| broken(dns_status
== ERROR_TIMEOUT
) || broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_W wrong status %lu expected %u or %u or %d\n", dns_status
, ERROR_INVALID_NAME
, ERROR_TIMEOUT
, DNS_ERROR_INVALID_NAME_CHAR
);
368 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
370 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
371 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
372 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
373 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
375 ok(dp
== NULL
|| broken(dp
== InvalidPointer
), "dp = %p\n", dp
);
376 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
378 dns_status
= DnsQuery_W(L
"0.0.0.0", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
379 ok(dns_status
== NO_ERROR
, "DnsQuery_W failed with error %lu\n", dns_status
);
380 if (dp
!= InvalidPointer
)
382 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"0.0.0.0") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"0.0.0.0");
383 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
384 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
385 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_ANY
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_ANY
));
387 ok(dp
!= InvalidPointer
&& dp
!= NULL
, "dp = %p\n", dp
);
388 if (dp
!= InvalidPointer
) DnsRecordListFree(dp
, DnsFreeRecordList
);
391 dns_status
= DnsQuery_W(L
"0.0.0.0 ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
392 ok(dns_status
== NO_ERROR
|| broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_W wrong status %lu expected %u or %u\n", dns_status
, NO_ERROR
, DNS_ERROR_INVALID_NAME_CHAR
);
393 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
395 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"0.0.0.0") == 0 || broken(wcscmp((LPCWSTR
)dp
->pName
, L
"0.0.0.0 ") == 0), "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"0.0.0.0");
396 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
397 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
398 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_ANY
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_ANY
));
400 ok(dp
!= InvalidPointer
|| broken(dp
== InvalidPointer
) || broken(dp
== NULL
), "dp = %p\n", dp
);
401 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
404 dns_status
= DnsQuery_W(L
"127.0.0.1 ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
405 ok(dns_status
== NO_ERROR
|| broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_W wrong status %lu expected %u or %u\n", dns_status
, NO_ERROR
, DNS_ERROR_INVALID_NAME_CHAR
);
406 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
408 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"127.0.0.1") == 0 || broken(wcscmp((LPCWSTR
)dp
->pName
, L
"127.0.0.1 ") == 0), "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"127.0.0.1");
409 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
410 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
411 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
413 ok(dp
!= InvalidPointer
|| broken(dp
== InvalidPointer
) || broken(dp
== NULL
), "dp = %p\n", dp
);
414 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
417 dns_status
= DnsQuery_W(L
" 127.0.0.1 ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
418 ok(dns_status
== DNS_ERROR_RCODE_NAME_ERROR
|| broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_W wrong status %lu expected %u or %u\n", dns_status
, DNS_ERROR_RCODE_NAME_ERROR
, DNS_ERROR_INVALID_NAME_CHAR
);
419 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
421 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
422 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
423 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
424 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
426 ok(dp
== NULL
|| broken(dp
== InvalidPointer
), "dp = %p\n", dp
);
427 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
430 dns_status
= DnsQuery_W(L
" 127.0. 0.1 ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
431 ok(dns_status
== DNS_ERROR_RCODE_NAME_ERROR
|| broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_W wrong status %lu expected %u or %u\n", dns_status
, DNS_ERROR_RCODE_NAME_ERROR
, DNS_ERROR_INVALID_NAME_CHAR
);
432 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
434 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
435 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
436 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
437 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
439 ok(dp
== NULL
|| broken(dp
== InvalidPointer
), "dp = %p\n", dp
);
440 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
443 dns_status
= DnsQuery_W(L
"localhost ", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
444 ok(dns_status
== ERROR_INVALID_NAME
|| broken(dns_status
== ERROR_TIMEOUT
) || broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_W wrong status %lu expected %u or %u or %u\n", dns_status
, ERROR_INVALID_NAME
, ERROR_TIMEOUT
, DNS_ERROR_INVALID_NAME_CHAR
);
445 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
447 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
448 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
449 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
450 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
452 ok(dp
== NULL
|| broken(dp
== InvalidPointer
), "dp = %p\n", dp
);
453 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
456 dns_status
= DnsQuery_W(L
" localhost", DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
457 ok(dns_status
== ERROR_INVALID_NAME
|| broken(dns_status
== ERROR_TIMEOUT
) || broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_W wrong status %lu expected %u or %u or %u\n", dns_status
, ERROR_INVALID_NAME
, ERROR_TIMEOUT
, DNS_ERROR_INVALID_NAME_CHAR
);
458 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
460 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
461 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
462 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
463 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
465 ok(dp
== NULL
|| broken(dp
== InvalidPointer
), "dp = %p\n", dp
);
466 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
469 wcscpy(test_nameW
, L
" local host ");
470 dns_status
= DnsQuery_W(test_nameW
, DNS_TYPE_A
, DNS_QUERY_STANDARD
, 0, &dp
, 0);
471 ok(dns_status
== ERROR_INVALID_NAME
|| broken(dns_status
== ERROR_TIMEOUT
) || broken(dns_status
== DNS_ERROR_INVALID_NAME_CHAR
), "DnsQuery_W wrong status %lu expected %u or %u or %u\n", dns_status
, ERROR_INVALID_NAME
, ERROR_TIMEOUT
, DNS_ERROR_INVALID_NAME_CHAR
);
472 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
)
474 ok(wcscmp((LPCWSTR
)dp
->pName
, L
"localhost") == 0, "DnsQuery_W returned wrong answer '%ls' expected '%ls'\n", (LPCWSTR
)dp
->pName
, L
"localhost");
475 ok(dp
->wType
== DNS_TYPE_A
, "DnsQuery_W returned wrong type %d expected %d\n", dp
->wType
, DNS_TYPE_A
);
476 ok(dp
->wDataLength
== sizeof(IP4_ADDRESS
), "DnsQuery_W returned wrong data size %d\n", dp
->wDataLength
);
477 ok(dp
->Data
.A
.IpAddress
== ntohl(INADDR_LOOPBACK
), "DnsQuery_W returned wrong data %ld expected %ld\n", dp
->Data
.A
.IpAddress
, ntohl(INADDR_LOOPBACK
));
479 ok(dp
== NULL
|| broken(dp
== InvalidPointer
), "dp = %p\n", dp
);
480 if (dp
!= InvalidPointer
&& dns_status
== NO_ERROR
) DnsRecordListFree(dp
, DnsFreeRecordList
);
488 // Initialize Winsock
489 iResult
= WSAStartup(MAKEWORD(2, 2), &wsaData
);
490 ok(iResult
== 0, "WSAStartup failed: %d\n", iResult
);
491 if (iResult
!= 0) return;