Commit 1691ca5e authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

dnsapi/tests: No need to dynamically load dnsapi anymore.

parent 7626e5ec
...@@ -3,7 +3,7 @@ TOPOBJDIR = ../../.. ...@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
TESTDLL = dnsapi.dll TESTDLL = dnsapi.dll
IMPORTS = kernel32 IMPORTS = dnsapi kernel32
CTESTS = \ CTESTS = \
name.c \ name.c \
......
...@@ -27,21 +27,6 @@ ...@@ -27,21 +27,6 @@
#include "wine/test.h" #include "wine/test.h"
static HMODULE dnsapi;
static BOOL (WINAPI *pDnsNameCompare_A)(LPSTR,LPSTR);
static DNS_STATUS (WINAPI *pDnsValidateName_A)(LPCSTR,DNS_NAME_FORMAT);
#define GETFUNCPTR(func) p##func = (void *)GetProcAddress( dnsapi, #func ); \
if (!p##func) return FALSE;
static BOOL init_function_ptrs( void )
{
GETFUNCPTR( DnsNameCompare_A )
GETFUNCPTR( DnsValidateName_A )
return TRUE;
}
static const struct static const struct
{ {
LPCSTR name; LPCSTR name;
...@@ -155,12 +140,12 @@ static void test_DnsValidateName_A( void ) ...@@ -155,12 +140,12 @@ static void test_DnsValidateName_A( void )
unsigned int i; unsigned int i;
DNS_STATUS status; DNS_STATUS status;
status = pDnsValidateName_A( NULL, DnsNameDomain ); status = DnsValidateName_A( NULL, DnsNameDomain );
ok( status == ERROR_INVALID_NAME, "succeeded unexpectedly\n" ); ok( status == ERROR_INVALID_NAME, "succeeded unexpectedly\n" );
for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++)
{ {
status = pDnsValidateName_A( test_data[i].name, test_data[i].format ); status = DnsValidateName_A( test_data[i].name, test_data[i].format );
ok( status == test_data[i].status, "%d: \'%s\': got %d, expected %d\n", ok( status == test_data[i].status, "%d: \'%s\': got %d, expected %d\n",
i, test_data[i].name, status, test_data[i].status ); i, test_data[i].name, status, test_data[i].status );
} }
...@@ -185,56 +170,39 @@ static void test_DnsNameCompare_A( void ) ...@@ -185,56 +170,39 @@ static void test_DnsNameCompare_A( void )
b_dot_a_dot[] = "b.a.", b_dot_a_dot[] = "b.a.",
b_dot_a_dotdot[] = "b.a.."; b_dot_a_dotdot[] = "b.a..";
ok( pDnsNameCompare_A( NULL, NULL ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( NULL, NULL ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( empty, empty ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( empty, empty ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( dot, empty ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( dot, empty ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( empty, dot ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( empty, dot ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( dot, dotdot ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( dot, dotdot ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( dotdot, dot ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( dotdot, dot ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( a, a ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( a, a ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( a, A ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( a, A ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( A, a ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( A, a ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b, A_dot_B ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b, A_dot_B ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b, a_dot_b ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b, a_dot_b ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b_dot, a_dot_b_dot ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b_dot, a_dot_b_dot ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b_dotdot, a_dot_b_dotdot ) == TRUE, "failed unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b_dotdot, a_dot_b_dotdot ) == TRUE, "failed unexpectedly\n" );
ok( pDnsNameCompare_A( empty, NULL ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( empty, NULL ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( NULL, empty ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( NULL, empty ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a, b ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a, b ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a, B ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a, B ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( A, b ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( A, b ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b, B_dot_A ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b, B_dot_A ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b_dot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b, a_dot_a ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b, a_dot_a ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b_dot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b_dot, b_dot_a ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsNameCompare_A( a_dot_b, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsNameCompare_A( a_dot_b, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
} }
START_TEST(name) START_TEST(name)
{ {
dnsapi = LoadLibraryA( "dnsapi.dll" );
if (!dnsapi)
{
/* Doesn't exist before W2K */
skip("dnsapi.dll cannot be loaded\n");
return;
}
if (!init_function_ptrs())
{
skip("Needed functions are not available\n");
FreeLibrary( dnsapi );
return;
}
test_DnsValidateName_A(); test_DnsValidateName_A();
test_DnsNameCompare_A(); test_DnsNameCompare_A();
FreeLibrary( dnsapi );
} }
...@@ -28,23 +28,6 @@ ...@@ -28,23 +28,6 @@
#include "wine/test.h" #include "wine/test.h"
static HMODULE dnsapi;
static BOOL (WINAPI *pDnsRecordCompare)(PDNS_RECORD,PDNS_RECORD);
static BOOL (WINAPI *pDnsRecordSetCompare)(PDNS_RECORD,PDNS_RECORD,PDNS_RECORD*,PDNS_RECORD*);
static DNS_RECORD* (WINAPI *pDnsRecordSetDetach)(PDNS_RECORD);
#define GETFUNCPTR(func) p##func = (void *)GetProcAddress( dnsapi, #func ); \
if (!p##func) return FALSE;
static BOOL init_function_ptrs( void )
{
GETFUNCPTR( DnsRecordCompare )
GETFUNCPTR( DnsRecordSetCompare )
GETFUNCPTR( DnsRecordSetDetach )
return TRUE;
}
static char name1[] = "localhost"; static char name1[] = "localhost";
static char name2[] = "LOCALHOST"; static char name2[] = "LOCALHOST";
...@@ -54,25 +37,25 @@ static DNS_RECORDA r3 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 12 ...@@ -54,25 +37,25 @@ static DNS_RECORDA r3 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 12
static void test_DnsRecordCompare( void ) static void test_DnsRecordCompare( void )
{ {
ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r1 ) == TRUE, "failed unexpectedly\n" ); ok( DnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r1 ) == TRUE, "failed unexpectedly\n" );
r2.pName = name2; r2.pName = name2;
ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == TRUE, "failed unexpectedly\n" ); ok( DnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == TRUE, "failed unexpectedly\n" );
r2.Flags.S.CharSet = DnsCharSetUnicode; r2.Flags.S.CharSet = DnsCharSetUnicode;
ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" );
r2.Flags.S.CharSet = DnsCharSetAnsi; r2.Flags.S.CharSet = DnsCharSetAnsi;
ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" );
r1.Flags.S.CharSet = DnsCharSetAnsi; r1.Flags.S.CharSet = DnsCharSetAnsi;
ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == TRUE, "failed unexpectedly\n" ); ok( DnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == TRUE, "failed unexpectedly\n" );
r1.dwTtl = 0; r1.dwTtl = 0;
ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == TRUE, "failed unexpectedly\n" ); ok( DnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == TRUE, "failed unexpectedly\n" );
r2.Data.A.IpAddress = 0; r2.Data.A.IpAddress = 0;
ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" );
} }
static void test_DnsRecordSetCompare( void ) static void test_DnsRecordSetCompare( void )
...@@ -94,36 +77,36 @@ static void test_DnsRecordSetCompare( void ) ...@@ -94,36 +77,36 @@ static void test_DnsRecordSetCompare( void )
DNS_RRSET_TERMINATE( rr1 ); DNS_RRSET_TERMINATE( rr1 );
DNS_RRSET_TERMINATE( rr2 ); DNS_RRSET_TERMINATE( rr2 );
ok( pDnsRecordSetCompare( NULL, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( NULL, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsRecordSetCompare( rr1.pFirstRR, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( rr1.pFirstRR, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsRecordSetCompare( NULL, rr2.pFirstRR, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( NULL, rr2.pFirstRR, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
diff1 = NULL; diff1 = NULL;
diff2 = NULL; diff2 = NULL;
ok( pDnsRecordSetCompare( NULL, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( NULL, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 ); ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
ok( pDnsRecordSetCompare( rr1.pFirstRR, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( rr1.pFirstRR, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
ok( diff1 != NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 ); ok( diff1 != NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
ok( pDnsRecordSetCompare( NULL, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( NULL, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
ok( diff1 == NULL && diff2 != NULL, "unexpected result: %p, %p\n", diff1, diff2 ); ok( diff1 == NULL && diff2 != NULL, "unexpected result: %p, %p\n", diff1, diff2 );
ok( pDnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == TRUE, "failed unexpectedly\n" ); ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == TRUE, "failed unexpectedly\n" );
ok( diff2 == NULL, "unexpected result: %p\n", diff2 ); ok( diff2 == NULL, "unexpected result: %p\n", diff2 );
ok( pDnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == TRUE, "failed unexpectedly\n" ); ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == TRUE, "failed unexpectedly\n" );
ok( diff1 == NULL, "unexpected result: %p\n", diff1 ); ok( diff1 == NULL, "unexpected result: %p\n", diff1 );
ok( pDnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == TRUE, "failed unexpectedly\n" ); ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == TRUE, "failed unexpectedly\n" );
ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 ); ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
r2.Data.A.IpAddress = 0; r2.Data.A.IpAddress = 0;
ok( pDnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == FALSE, "succeeded unexpectedly\n" );
ok( pDnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" ); ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
} }
static void test_DnsRecordSetDetach( void ) static void test_DnsRecordSetDetach( void )
...@@ -137,10 +120,10 @@ static void test_DnsRecordSetDetach( void ) ...@@ -137,10 +120,10 @@ static void test_DnsRecordSetDetach( void )
DNS_RRSET_ADD( rr, &r3 ); DNS_RRSET_ADD( rr, &r3 );
DNS_RRSET_TERMINATE( rr ); DNS_RRSET_TERMINATE( rr );
ok( !pDnsRecordSetDetach( NULL ), "succeeded unexpectedly\n" ); ok( !DnsRecordSetDetach( NULL ), "succeeded unexpectedly\n" );
r = rr.pFirstRR; r = rr.pFirstRR;
s = pDnsRecordSetDetach( r ); s = DnsRecordSetDetach( r );
ok( s == &r3, "failed unexpectedly: got %p, expected %p\n", s, &r3 ); ok( s == &r3, "failed unexpectedly: got %p, expected %p\n", s, &r3 );
ok( r == &r1, "failed unexpectedly: got %p, expected %p\n", r, &r1 ); ok( r == &r1, "failed unexpectedly: got %p, expected %p\n", r, &r1 );
...@@ -149,24 +132,7 @@ static void test_DnsRecordSetDetach( void ) ...@@ -149,24 +132,7 @@ static void test_DnsRecordSetDetach( void )
START_TEST(record) START_TEST(record)
{ {
dnsapi = LoadLibraryA( "dnsapi.dll" );
if (!dnsapi)
{
/* Doesn't exist before W2K */
skip("dnsapi.dll cannot be loaded\n");
return;
}
if (!init_function_ptrs())
{
skip("Needed functions are not available\n");
FreeLibrary( dnsapi );
return;
}
test_DnsRecordCompare(); test_DnsRecordCompare();
test_DnsRecordSetCompare(); test_DnsRecordSetCompare();
test_DnsRecordSetDetach(); test_DnsRecordSetDetach();
FreeLibrary( dnsapi );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment