2006-05-01 16:29:05 +02:00
|
|
|
/*
|
|
|
|
* Tests for record handling functions
|
|
|
|
*
|
|
|
|
* Copyright 2006 Hans Leidekker
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-05-01 16:29:05 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2006-05-08 16:39:23 +02:00
|
|
|
#include <stdio.h>
|
2006-05-01 16:29:05 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "windns.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2020-12-09 00:33:57 +01:00
|
|
|
static WCHAR name1[] = L"localhost";
|
|
|
|
static WCHAR name2[] = L"LOCALHOST";
|
2006-05-08 16:39:23 +02:00
|
|
|
|
2013-10-14 15:56:54 +02:00
|
|
|
static DNS_RECORDW r1 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
|
|
|
|
static DNS_RECORDW r2 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
|
|
|
|
static DNS_RECORDW r3 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
|
2006-05-08 16:39:23 +02:00
|
|
|
|
2006-05-01 16:29:05 +02:00
|
|
|
static void test_DnsRecordCompare( void )
|
|
|
|
{
|
2009-01-01 23:26:59 +01:00
|
|
|
ok( DnsRecordCompare( &r1, &r1 ) == TRUE, "failed unexpectedly\n" );
|
2006-05-01 16:29:05 +02:00
|
|
|
|
|
|
|
r2.pName = name2;
|
2009-01-01 23:26:59 +01:00
|
|
|
ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
|
2006-05-01 16:29:05 +02:00
|
|
|
|
|
|
|
r2.Flags.S.CharSet = DnsCharSetUnicode;
|
2013-10-14 15:56:54 +02:00
|
|
|
ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
|
2006-05-01 16:29:05 +02:00
|
|
|
|
|
|
|
r2.Flags.S.CharSet = DnsCharSetAnsi;
|
2013-10-14 15:56:54 +02:00
|
|
|
ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
|
2006-05-01 16:29:05 +02:00
|
|
|
|
|
|
|
r1.Flags.S.CharSet = DnsCharSetAnsi;
|
2009-01-01 23:26:59 +01:00
|
|
|
ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
|
2006-05-01 16:29:05 +02:00
|
|
|
|
2006-05-09 12:04:44 +02:00
|
|
|
r1.dwTtl = 0;
|
2009-01-01 23:26:59 +01:00
|
|
|
ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
|
2006-05-09 12:04:44 +02:00
|
|
|
|
2006-05-01 16:29:05 +02:00
|
|
|
r2.Data.A.IpAddress = 0;
|
2009-01-01 23:26:59 +01:00
|
|
|
ok( DnsRecordCompare( &r1, &r2 ) == FALSE, "succeeded unexpectedly\n" );
|
2006-05-01 16:29:05 +02:00
|
|
|
}
|
|
|
|
|
2006-05-08 16:39:23 +02:00
|
|
|
static void test_DnsRecordSetCompare( void )
|
|
|
|
{
|
2013-10-14 15:56:54 +02:00
|
|
|
DNS_RECORDW *diff1;
|
|
|
|
DNS_RECORDW *diff2;
|
2006-05-08 16:39:23 +02:00
|
|
|
DNS_RRSET rr1, rr2;
|
|
|
|
|
|
|
|
r1.Flags.DW = 0x2019;
|
|
|
|
r2.Flags.DW = 0x2019;
|
|
|
|
r2.Data.A.IpAddress = 0xffffffff;
|
|
|
|
|
|
|
|
DNS_RRSET_INIT( rr1 );
|
|
|
|
DNS_RRSET_INIT( rr2 );
|
|
|
|
|
|
|
|
DNS_RRSET_ADD( rr1, &r1 );
|
|
|
|
DNS_RRSET_ADD( rr2, &r2 );
|
|
|
|
|
|
|
|
DNS_RRSET_TERMINATE( rr1 );
|
|
|
|
DNS_RRSET_TERMINATE( rr2 );
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( NULL, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
|
|
|
|
ok( DnsRecordSetCompare( rr1.pFirstRR, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
|
|
|
|
ok( DnsRecordSetCompare( NULL, rr2.pFirstRR, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
|
2006-05-08 16:39:23 +02:00
|
|
|
|
|
|
|
diff1 = NULL;
|
|
|
|
diff2 = NULL;
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( NULL, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
|
2006-05-08 16:39:23 +02:00
|
|
|
ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( rr1.pFirstRR, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
|
2006-05-08 16:39:23 +02:00
|
|
|
ok( diff1 != NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
|
2008-07-19 19:53:35 +02:00
|
|
|
DnsRecordListFree( diff1, DnsFreeRecordList );
|
2006-05-08 16:39:23 +02:00
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( NULL, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
|
2006-05-08 16:39:23 +02:00
|
|
|
ok( diff1 == NULL && diff2 != NULL, "unexpected result: %p, %p\n", diff1, diff2 );
|
2008-07-19 19:53:35 +02:00
|
|
|
DnsRecordListFree( diff2, DnsFreeRecordList );
|
2006-05-08 16:39:23 +02:00
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == TRUE, "failed unexpectedly\n" );
|
2006-05-08 16:39:23 +02:00
|
|
|
ok( diff2 == NULL, "unexpected result: %p\n", diff2 );
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == TRUE, "failed unexpectedly\n" );
|
2006-05-08 16:39:23 +02:00
|
|
|
ok( diff1 == NULL, "unexpected result: %p\n", diff1 );
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == TRUE, "failed unexpectedly\n" );
|
2006-05-08 16:39:23 +02:00
|
|
|
ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
|
|
|
|
|
|
|
|
r2.Data.A.IpAddress = 0;
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
|
2008-07-19 19:53:35 +02:00
|
|
|
DnsRecordListFree( diff2, DnsFreeRecordList );
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == FALSE, "succeeded unexpectedly\n" );
|
2008-07-19 19:53:35 +02:00
|
|
|
DnsRecordListFree( diff1, DnsFreeRecordList );
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
|
2008-07-19 19:53:35 +02:00
|
|
|
DnsRecordListFree( diff1, DnsFreeRecordList );
|
|
|
|
DnsRecordListFree( diff2, DnsFreeRecordList );
|
2006-05-08 16:39:23 +02:00
|
|
|
}
|
|
|
|
|
2006-09-13 14:36:33 +02:00
|
|
|
static void test_DnsRecordSetDetach( void )
|
|
|
|
{
|
|
|
|
DNS_RRSET rr;
|
2013-10-14 15:56:54 +02:00
|
|
|
DNS_RECORDW *r, *s;
|
2006-09-13 14:36:33 +02:00
|
|
|
|
|
|
|
DNS_RRSET_INIT( rr );
|
|
|
|
DNS_RRSET_ADD( rr, &r1 );
|
|
|
|
DNS_RRSET_ADD( rr, &r2 );
|
|
|
|
DNS_RRSET_ADD( rr, &r3 );
|
|
|
|
DNS_RRSET_TERMINATE( rr );
|
|
|
|
|
2007-08-21 17:38:19 +02:00
|
|
|
ok( !DnsRecordSetDetach( NULL ), "succeeded unexpectedly\n" );
|
2006-09-13 14:36:33 +02:00
|
|
|
|
|
|
|
r = rr.pFirstRR;
|
2007-08-21 17:38:19 +02:00
|
|
|
s = DnsRecordSetDetach( r );
|
2006-09-13 14:36:33 +02:00
|
|
|
|
|
|
|
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( !r2.pNext, "failed unexpectedly\n" );
|
|
|
|
}
|
|
|
|
|
2006-05-01 16:29:05 +02:00
|
|
|
START_TEST(record)
|
|
|
|
{
|
|
|
|
test_DnsRecordCompare();
|
2006-05-08 16:39:23 +02:00
|
|
|
test_DnsRecordSetCompare();
|
2006-09-13 14:36:33 +02:00
|
|
|
test_DnsRecordSetDetach();
|
2006-05-01 16:29:05 +02:00
|
|
|
}
|