Author: akhaldi
Date: Fri Sep 30 15:23:25 2016
New Revision: 72868
URL:
http://svn.reactos.org/svn/reactos?rev=72868&view=rev
Log:
[DNSAPI_APITEST] Add more tests for DnsQuery_A/W. By Peter Hater. ROSTESTS-242
Modified:
trunk/rostests/apitests/dnsapi/CMakeLists.txt
trunk/rostests/apitests/dnsapi/DnsQuery.c
Modified: trunk/rostests/apitests/dnsapi/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/dnsapi/CMakeList…
==============================================================================
--- trunk/rostests/apitests/dnsapi/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/dnsapi/CMakeLists.txt [iso-8859-1] Fri Sep 30 15:23:25 2016
@@ -6,5 +6,5 @@
add_executable(dnsapi_apitest ${SOURCE})
target_link_libraries(dnsapi_apitest wine)
set_module_type(dnsapi_apitest win32cui)
-add_importlibs(dnsapi_apitest ws2_32 dnsapi msvcrt kernel32 ntdll)
+add_importlibs(dnsapi_apitest ws2_32 dnsapi iphlpapi msvcrt kernel32 ntdll)
add_cd_file(TARGET dnsapi_apitest DESTINATION reactos/bin FOR all)
Modified: trunk/rostests/apitests/dnsapi/DnsQuery.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/dnsapi/DnsQuery.…
==============================================================================
--- trunk/rostests/apitests/dnsapi/DnsQuery.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/dnsapi/DnsQuery.c [iso-8859-1] Fri Sep 30 15:23:25 2016
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <windns.h>
#include <apitest.h>
+#include <iphlpapi.h>
void TestHostName(void)
@@ -17,22 +18,40 @@
DNS_STATUS dns_status;
char host_name[255];
- char domain_name[255];
char test_name[255];
PDNS_RECORD dp;
WCHAR host_nameW[255];
WCHAR test_nameW[255];
- DWORD size = sizeof(host_name);
-
- GetComputerNameEx(ComputerNameDnsHostname, host_name, &size);
- size = sizeof(domain_name);
- GetComputerNameEx(ComputerNameDnsDomain, domain_name, &size);
- if (strlen(domain_name))
- {
- strcat(host_name, ".");
- strcat(host_name, domain_name);
- }
- mbstowcs(host_nameW, host_name, 255);
+ PFIXED_INFO network_info;
+ ULONG network_info_blen = 0;
+ DWORD network_info_result;
+
+ network_info_result = GetNetworkParams(NULL, &network_info_blen);
+ network_info = (PFIXED_INFO)HeapAlloc(GetProcessHeap(), 0,
(size_t)network_info_blen);
+ if (NULL == network_info)
+ {
+ skip("Not enough memory. Can't continue!\n");
+ return;
+ }
+
+ network_info_result = GetNetworkParams(network_info, &network_info_blen);
+ if (network_info_result != ERROR_SUCCESS)
+ {
+ HeapFree(GetProcessHeap(), 0, network_info);
+ skip("Can't get network info. Some results may be wrong.\n");
+ return;
+ }
+ else
+ {
+ strcpy(host_name, network_info->HostName);
+ if (strlen(network_info->DomainName))
+ {
+ strcat(host_name, ".");
+ strcat(host_name, network_info->DomainName);
+ }
+ HeapFree(GetProcessHeap(), 0, network_info);
+ mbstowcs(host_nameW, host_name, 255);
+ }
//DnsQuery_A:
//NULL
@@ -40,7 +59,11 @@
dns_status = DnsQuery_A(NULL, DNS_TYPE_A, DNS_QUERY_STANDARD, 0, &dp, 0);
ok(dns_status == ERROR_INVALID_PARAMETER, "DnsQuery_A failed with error
%lu\n", dns_status);
ok(dp == InvalidPointer, "dp = %p\n", dp);
-
+
+ //NULL dp
+ dns_status = DnsQuery_A(host_name, DNS_TYPE_A, DNS_QUERY_STANDARD, 0, NULL, 0);
+ ok(dns_status == ERROR_INVALID_PARAMETER, "DnsQuery_A failed with error
%lu\n", dns_status);
+
//Testing HostName
dp = InvalidPointer;
dns_status = DnsQuery_A(host_name, DNS_TYPE_A, DNS_QUERY_STANDARD, 0, &dp, 0);
@@ -260,6 +283,10 @@
ok(dp == InvalidPointer, "dp = %p\n", dp);
}
if (dp != InvalidPointer) DnsRecordListFree(dp, DnsFreeRecordList);
+
+ //NULL dp
+ dns_status = DnsQuery_W(host_nameW, DNS_TYPE_A, DNS_QUERY_STANDARD, 0, NULL, 0);
+ ok(dns_status == ERROR_INVALID_PARAMETER, "DnsQuery_W failed with error
%lu\n", dns_status);
//Testing HostName
dns_status = DnsQuery_W(host_nameW, DNS_TYPE_A, DNS_QUERY_STANDARD, 0, &dp, 0);