[DNSAPI_APITEST] Add more tests for DnsQuery_A/W. By Peter Hater. ROSTESTS-242

svn path=/trunk/; revision=72868
This commit is contained in:
Amine Khaldi 2016-09-30 15:23:25 +00:00
parent 040de105cc
commit 8e21414853
2 changed files with 38 additions and 11 deletions

View file

@ -6,5 +6,5 @@ list(APPEND SOURCE
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)

View file

@ -10,6 +10,7 @@
#include <stdio.h>
#include <windns.h>
#include <apitest.h>
#include <iphlpapi.h>
void TestHostName(void)
@ -17,22 +18,40 @@ void TestHostName(void)
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);
PFIXED_INFO network_info;
ULONG network_info_blen = 0;
DWORD network_info_result;
GetComputerNameEx(ComputerNameDnsHostname, host_name, &size);
size = sizeof(domain_name);
GetComputerNameEx(ComputerNameDnsDomain, domain_name, &size);
if (strlen(domain_name))
network_info_result = GetNetworkParams(NULL, &network_info_blen);
network_info = (PFIXED_INFO)HeapAlloc(GetProcessHeap(), 0, (size_t)network_info_blen);
if (NULL == network_info)
{
strcat(host_name, ".");
strcat(host_name, domain_name);
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);
}
mbstowcs(host_nameW, host_name, 255);
//DnsQuery_A:
//NULL
@ -40,7 +59,11 @@ void TestHostName(void)
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);
@ -261,6 +284,10 @@ void TestHostName(void)
}
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);
ok(dns_status == NO_ERROR, "DnsQuery_W failed with error %lu\n", dns_status);