@@ -9,27 +9,32 @@
* information regarding copyright ownership.
*/
/*! \file */
# include <config.h>
# include <atf-c.h>
# if HAVE_CMOCKA
# include <stdarg.h>
# include <stddef.h>
# include <setjmp.h>
# include <stdbool.h>
# include <stdlib.h>
# include <string.h>
# include <unistd.h>
# define UNIT_TESTING
# include <cmocka.h>
# include <isc/hex.h>
# include <isc/lex.h>
# include <isc/stdio.h>
# include <isc/types.h>
# include <isc/util.h>
# include <dns/callbacks.h>
# include <dns/rdata.h>
# include "dnstest.h"
/*****
***** Commonly used structures
*****/
/*
* An array of these structures is passed to compare_ok().
*/
@@ -41,31 +46,44 @@ struct compare_ok {
} ;
typedef struct compare_ok compare_ok_t ;
static int
_setup ( void * * state ) {
isc_result_t result ;
UNUSED ( state ) ;
result = dns_test_begin ( NULL , false ) ;
assert_int_equal ( result , ISC_R_SUCCESS ) ;
return ( 0 ) ;
}
static int
_teardown ( void * * state ) {
UNUSED ( state ) ;
dns_test_end ( ) ;
return ( 0 ) ;
}
/*
* An array of these structures is passed to check_text_ok().
*/
struct text_ok {
typedef struct text_ok {
const char * text_in ; /* text passed to fromtext_*() */
const char * text_out ; /* text expected from totext_*();
NULL indicates text_in is invalid */
int lineno ; /* source line defining this RDATA */
} ;
typedef struct text_ok text_ok_t ;
} text_ok_t ;
/*
* An array of these structures is passed to check_wire_ok().
*/
struct wire_ok {
typedef struct wire_ok {
unsigned char data [ 512 ] ; /* RDATA in wire format */
size_t len ; /* octets of data to parse */
bool ok ; /* is this RDATA valid? */
int lineno ; /* source line defining this RDATA */
} ;
typedef struct wire_ok wire_ok_t ;
/*****
***** Convenience macros for creating the above structures
*****/
bool ok ; /* is this RDATA valid? */
} wire_ok_t ;
# define COMPARE(r1, r2, answer) \
{ r1, r2, answer, __LINE__ }
@@ -73,24 +91,20 @@ typedef struct wire_ok wire_ok_t;
{ NULL, NULL, 0, __LINE__ }
# define TEXT_VALID_CHANGED(data_in, data_out) \
{ data_in, data_out, __LINE__ }
# define TEXT_VALID(data) { data, data, __LINE__ }
# define TEXT_INVALID(data) { data, NULL, __LINE__ }
{ data_in, data_out }
# define TEXT_VALID(data) { data, data }
# define TEXT_INVALID(data) { data, NULL }
# define TEXT_SENTINEL() TEXT_INVALID(NULL)
# define VARGC(...) (sizeof((unsigned char[]){ __VA_ARGS__ }))
# define WIRE_TEST(ok, ...) { \
{ __VA_ARGS__ }, VARGC(__VA_ARGS__), \
ok, __LINE__ \
ok \
}
# define WIRE_VALID(...) WIRE_TEST(true, __VA_ARGS__)
# define WIRE_INVALID(...) WIRE_TEST(false, __VA_ARGS__)
# define WIRE_SENTINEL() WIRE_TEST(false)
/*****
***** Checking functions used by test cases
*****/
/*
* Test whether converting rdata to a type-specific struct and then back to
* rdata results in the same uncompressed wire form. This checks whether
@@ -101,52 +115,37 @@ typedef struct wire_ok wire_ok_t;
* check_text_ok_single() and check_wire_ok_single().
*/
static void
check_struct_conversions ( dns_rdata_t * rdata , size_t structsize , int lineno ) {
check_struct_conversions ( dns_rdata_t * rdata , size_t structsize ) {
dns_rdataclass_t rdclass = rdata - > rdclass ;
dns_rdatatype_t type = rdata - > type ;
isc_result_t result ;
isc_buffer_t target ;
void * rdata_struct ;
char buf [ 1024 ] , hex [ BUFSIZ ] ;
char buf [ 1024 ] ;
rdata_struct = isc_mem_allocate ( mctx , structsize ) ;
ATF_REQUIRE ( rdata_struct ! = NULL ) ;
assert_non_null ( rdata_struct ) ;
/*
* Convert from uncompressed wire form into type-specific struct.
*/
result = dns_rdata_tostruct ( rdata , rdata_struct , NULL ) ;
ATF_REQUIRE_EQ_MSG ( result , ISC_R_SUCCESS ,
" %s (%u): dns_rdata_tostruct() failed " ,
dns_test_tohex ( rdata - > data , rdata - > length ,
hex , sizeof ( hex ) ) ,
rdata - > length ) ;
assert_int_equal ( result , ISC_R_SUCCESS ) ;
/*
* Convert from type-specific struct into uncompressed wire form.
*/
isc_buffer_init ( & target , buf , sizeof ( buf ) ) ;
result = dns_rdata_fromstruct ( NULL , rdclass , type , rdata_struct ,
& target ) ;
ATF_REQUIRE_EQ_MSG ( result , ISC_R_SUCCESS ,
" line %d: %s (%u): dns_rdata_fromstruct() failed " ,
lineno , dns_test_tohex ( rdata - > data , rdata - > length ,
hex , sizeof ( hex ) ) ,
rdata - > length ) ;
assert_int_equal ( result , ISC_R_SUCCESS ) ;
/*
* Ensure results are consistent.
*/
ATF_REQUIRE_EQ_MSG ( isc_buffer_usedlength ( & target ) , rdata - > length ,
" line %d: %s (%u): wire form data length changed "
" after converting to type-specific struct and back " ,
lineno , dns_test_tohex ( rdata - > data , rdata - > length ,
hex , sizeof ( hex ) ) ,
rdata - > length ) ;
ATF_REQUIRE_EQ_MSG ( memcmp ( buf , rdata - > data , rdata - > length ) , 0 ,
" line %d: %s (%u): wire form data different after "
" converting to type-specific struct and back " ,
lineno , dns_test_tohex ( rdata - > data , rdata - > length ,
hex , sizeof ( hex ) ) ,
rdata - > length ) ;
assert_int_equal ( isc_buffer_usedlength ( & target ) , rdata - > length ) ;
assert_memory_equal ( buf , rdata - > data , rdata - > length ) ;
isc_mem_free ( mctx , rdata_struct ) ;
}
@@ -171,21 +170,16 @@ check_text_ok_single(const text_ok_t *text_ok, dns_rdataclass_t rdclass,
*/
result = dns_test_rdatafromstring ( & rdata , rdclass , type , buf_fromtext ,
sizeof ( buf_fromtext ) ,
text_ok - > text_in ) ;
text_ok - > text_in , false );
/*
* Check whether result is as expected.
*/
if ( text_ok - > text_out ! = NULL ) {
ATF_REQUIRE_EQ_MSG ( result , ISC_R_SUCCESS ,
" line %d: '%s': "
" expected success, got failure " ,
text_ok - > lineno , text_ok - > text_in ) ;
assert_int_equal ( result , ISC_R_SUCCESS ) ;
} else {
ATF_REQUIRE_MSG ( result ! = ISC_R_SUCCESS ,
" line %d: '%s': "
" expected failure, got success " ,
text_ok - > lineno , text_ok - > text_in ) ;
assert_int_not_equal ( result , ISC_R_SUCCESS ) ;
}
/*
* If text form RDATA was not parsed correctly, performing any
* additional checks is pointless.
@@ -199,20 +193,14 @@ check_text_ok_single(const text_ok_t *text_ok, dns_rdataclass_t rdclass,
*/
isc_buffer_init ( & target , buf_totext , sizeof ( buf_totext ) ) ;
result = dns_rdata_totext ( & rdata , NULL , & target ) ;
ATF_REQUIRE_EQ_MSG ( result , ISC_R_SUCCESS ,
" line %d: '%s': "
" failed to convert rdata back to text form " ,
text_ok - > lineno , text_ok - > text_in ) ;
ATF_REQUIRE_EQ_MSG ( strcmp ( buf_totext , text_ok - > text_out ) , 0 ,
" line %d: '%s': "
" converts back to '%s', expected '%s' " ,
text_ok - > lineno , text_ok - > text_in , buf_totext ,
text_ok - > text_out ) ;
assert_int_equal ( result , ISC_R_SUCCESS ) ;
assert_string_equal ( buf_totext , text_ok - > text_out ) ;
/*
* Perform two-way conversion checks between uncompressed wire form and
* type-specific struct.
*/
check_struct_conversions ( & rdata , structsize , text_ok - > lineno );
check_struct_conversions ( & rdata , structsize ) ;
}
/*
@@ -228,7 +216,6 @@ check_wire_ok_single(const wire_ok_t *wire_ok, dns_rdataclass_t rdclass,
dns_decompress_t dctx ;
isc_result_t result ;
dns_rdata_t rdata ;
char hex [ BUFSIZ ] ;
/*
* Set up len-octet buffer pointing at data.
@@ -252,28 +239,16 @@ check_wire_ok_single(const wire_ok_t *wire_ok, dns_rdataclass_t rdclass,
* Check whether result is as expected.
*/
if ( wire_ok - > ok ) {
ATF_REQUIRE_EQ_MSG ( result , ISC_R_SUCCESS ,
" line %d: %s (%lu): "
" expected success, got failure " ,
wire_ok - > lineno ,
dns_test_tohex ( wire_ok - > data , wire_ok - > len ,
hex , sizeof ( hex ) ) ,
( unsigned long ) wire_ok - > len ) ;
assert_int_equal ( result , ISC_R_SUCCESS ) ;
} else {
ATF_REQUIRE_MSG ( result ! = ISC_R_SUCCESS ,
" line %d: %s (%lu): "
" expected failure, got success " ,
wire_ok - > lineno ,
dns_test_tohex ( wire_ok - > data , wire_ok - > len ,
hex , sizeof ( hex ) ) ,
( unsigned long ) wire_ok - > len ) ;
assert_int_not_equal ( result , ISC_R_SUCCESS ) ;
}
/*
* If data was parsed correctly, perform two-way conversion checks
* between uncompressed wire form and type-specific struct.
*/
if ( result = = ISC_R_SUCCESS ) {
check_struct_conversions ( & rdata , structsize , wire_ok - > lineno );
check_struct_conversions ( & rdata , structsize ) ;
}
}
@@ -339,44 +314,42 @@ check_compare_ok_single(const compare_ok_t *compare_ok,
result = dns_test_rdatafromstring ( & rdata1 , rdclass , type ,
buf1 , sizeof ( buf1 ) ,
compare_ok - > text1 ) ;
ATF_REQUIRE_EQ_MSG ( result , ISC_R_SUCCESS , " line %d: '%s': "
" expected success, got failure " ,
compare_ok - > lineno , compare_ok - > text1 ) ;
compare_ok - > text1 , false );
if ( result ! = ISC_R_SUCCESS ) {
fail_msg ( " # line %d: '%s': expected success, got failure " ,
compare_ok - > lineno , compare_ok - > text1 ) ;
}
result = dns_test_rdatafromstring ( & rdata2 , rdclass , type ,
buf2 , sizeof ( buf2 ) ,
compare_ok - > text2 ) ;
compare_ok - > text2 , false );
ATF_REQUIRE_EQ_MSG ( result , ISC_R_SUCCESS , " line %d: '%s': "
" expected success, got failure " ,
compare_ok - > lineno , compare_ok - > text2 ) ;
if ( result ! = ISC_R_SUCCESS ) {
fail_msg ( " # line %d: '%s': expected success, got failure" ,
compare_ok - > lineno , compare_ok - > text2 ) ;
}
answer = dns_rdata_compare ( & rdata1 , & rdata2 ) ;
if ( compare_ok - > answer = = 0 ) {
ATF_REQUIRE_MSG ( answer = = 0 ,
" line %d: dns_rdata_compare('%s', '%s'): "
" expected equal, got %s " ,
compare_ok - > lineno ,
compare_ok - > text1 , compare_ok - > text2 ,
( answer > 0 ) ? " greater than " : " less than " ) ;
if ( compare_ok - > answer = = 0 & & answer ! = 0 ) {
fail_msg ( " # line %d: dns_rdata_compare('%s', '%s'): "
" expected equal, got %s " ,
compare_ok - > lineno ,
compare_ok - > text1 , compare_ok - > text2 ,
( answer > 0 ) ? " greater than " : " less than " ) ;
}
if ( compare_ok - > answer < 0 ) {
ATF_REQUIRE_MSG ( answer < 0 ,
" line %d: dns_rdata_compare('%s', '%s'): "
" expected less than, got %s " ,
compare_ok - > lineno ,
compare_ok - > text1 , compare_ok - > text2 ,
( answer = = 0 ) ? " equal " : " greater than " ) ;
if ( compare_ok - > answer < 0 & & answer > = 0 ) {
fail_msg ( " # line %d: dns_rdata_compare('%s', '%s'): "
" expected less than, got %s " ,
compare_ok - > lineno ,
compare_ok - > text1 , compare_ok - > text2 ,
( answer = = 0 ) ? " equal " : " greater than " ) ;
}
if ( compare_ok - > answer > 0 ) {
ATF_REQUIRE_MSG ( answer > 0 ,
" line %d: dns_rdata_compare('%s', '%s'): "
" expected greater than, got %s " ,
compare_ok - > lineno ,
compare_ok - > text1 , compare_ok - > text2 ,
( answer = = 0 ) ? " equal " : " less than " ) ;
if ( compare_ok - > answer > 0 & & answer < = 0 ) {
fail_msg ( " line %d: dns_rdata_compare('%s', '%s'): "
" expected greater than, got %s " ,
compare_ok - > lineno ,
compare_ok - > text1 , compare_ok - > text2 ,
( answer = = 0 ) ? " equal " : " less than " ) ;
}
}
@@ -399,9 +372,7 @@ check_compare_ok(const compare_ok_t *compare_ok,
/*
* Test whether supplied sets of text form and/or wire form RDATA are handled
* as expected. This is just a helper function which should be the only
* function called for a test case using it, due to the use of dns_test_begin()
* and dns_test_end().
* as expected.
*
* The empty_ok argument denotes whether an attempt to parse a zero-length wire
* data buffer should succeed or not (it is valid for some RR types). There is
@@ -415,11 +386,6 @@ check_rdata(const text_ok_t *text_ok, const wire_ok_t *wire_ok,
bool empty_ok , dns_rdataclass_t rdclass ,
dns_rdatatype_t type , size_t structsize )
{
isc_result_t result ;
result = dns_test_begin ( NULL , false ) ;
ATF_REQUIRE_EQ ( result , ISC_R_SUCCESS ) ;
if ( text_ok ! = NULL ) {
check_text_ok ( text_ok , rdclass , type , structsize ) ;
}
@@ -429,19 +395,11 @@ check_rdata(const text_ok_t *text_ok, const wire_ok_t *wire_ok,
if ( compare_ok ! = NULL ) {
check_compare_ok ( compare_ok , rdclass , type ) ;
}
dns_test_end ( ) ;
}
/*****
***** Individual unit tests
*****/
ATF_TC ( apl ) ;
ATF_TC_HEAD ( apl , tc ) {
atf_tc_set_md_var ( tc , " descr " , " APL RDATA manipulations " ) ;
}
ATF_TC_BODY ( apl , tc ) {
/* APL RDATA manipulations */
static void
apl ( void * * state ) {
text_ok_t text_ok [ ] = {
/* empty list */
TEXT_VALID ( " " ) ,
@@ -489,17 +447,51 @@ ATF_TC_BODY(apl, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , wire_ok , NULL , true , dns_rdataclass_in ,
dns_rdatatype_apl , sizeof ( dns_rdata_in_apl_t ) ) ;
}
ATF_TC ( atma ) ;
ATF_TC_HEAD ( atma , tc ) {
atf_tc_set_md_var ( tc , " descr " , " ATMA RDATA manipulations " ) ;
}
ATF_TC_BODY ( atma , tc ) {
/*
* http://broadband-forum.org/ftp/pub/approved-specs/af-saa-0069.000.pdf
*
* ATMA RR’ s have the following RDATA format:
*
* 1 1 1 1 1 1
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | FORMAT | |
* +--+--+--+--+--+--+--+--+ |
* / ADDRESS /
* | |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*
* The fields have the following meaning:
*
* * FORMAT: One octet that indicates the format of ADDRESS. The two
* possible values for FORMAT are value 0 indicating ATM End System Address
* (AESA) format and value 1 indicating E.164 format.
*
* * ADDRESS: Variable length string of octets containing the ATM address of
* the node to which this RR pertains.
*
* When the format value is 0, indicating that the address is in AESA format,
* the address is coded as described in ISO 8348/AD 2 using the preferred
* binary encoding of the ISO NSAP format. When the format value is 1,
* indicating that the address is in E.164 format, the Address/Number Digits
* appear in the order in which they would be entered on a numeric keypad.
* Digits are coded in IA5 characters with the leftmost bit of each digit set
* to 0. This ATM address appears in ATM End System Address Octets field (AESA
* format) or the Address/Number Digits field (E.164 format) of the Called
* party number information element [ATMUNI3.1]. Subaddress information is
* intentionally not included because E.164 subaddress information is used for
* routing.
*
* ATMA RRs cause no additional section processing.
*/
static void
atma ( void * * state ) {
text_ok_t text_ok [ ] = {
TEXT_VALID ( " 00 " ) ,
TEXT_VALID_CHANGED ( " 0.0 " , " 00 " ) ,
@@ -564,7 +556,7 @@ ATF_TC_BODY(atma, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , wire_ok , NULL , false , dns_rdataclass_in ,
dns_rdatatype_atma , sizeof ( dns_rdata_in_atma_t ) ) ;
@@ -634,11 +626,8 @@ ATF_TC_BODY(atma, tc) {
* must understand the semantics associated with a bit in the Type Bit
* Map field that has been set to 1.
*/
ATF_TC ( csync ) ;
ATF_TC_HEAD ( csync , tc ) {
atf_tc_set_md_var ( tc , " descr " , " CSYNC RDATA manipulations " ) ;
}
ATF_TC_BODY ( csync , tc ) {
static void
csync ( void * * state ) {
text_ok_t text_ok [ ] = {
TEXT_INVALID ( " " ) ,
TEXT_INVALID ( " 0 " ) ,
@@ -695,7 +684,7 @@ ATF_TC_BODY(csync, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , wire_ok , NULL , false , dns_rdataclass_in ,
dns_rdatatype_csync , sizeof ( dns_rdata_csync_t ) ) ;
@@ -761,11 +750,8 @@ ATF_TC_BODY(csync, tc) {
* character ("-", ASCII 45). White space is permitted within Base64
* data.
*/
ATF_TC ( doa ) ;
ATF_TC_HEAD ( doa , tc ) {
atf_tc_set_md_var ( tc , " descr " , " DOA RDATA manipulations " ) ;
}
ATF_TC_BODY ( doa , tc ) {
static void
doa ( void * * state ) {
text_ok_t text_ok [ ] = {
/*
* Valid, non-empty DOA-DATA.
@@ -913,7 +899,7 @@ ATF_TC_BODY(doa, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , wire_ok , NULL , false , dns_rdataclass_in ,
dns_rdatatype_doa , sizeof ( dns_rdata_doa_t ) ) ;
@@ -979,12 +965,8 @@ ATF_TC_BODY(doa, tc) {
* All fields are in network byte order ("big-endian", per [RFC1700],
* Data Notation).
*/
ATF_TC ( edns_client_subnet ) ;
ATF_TC_HEAD ( edns_client_subnet, tc ) {
atf_tc_set_md_var ( tc , " descr " ,
" OPT RDATA with EDNS Client Subnet manipulations " ) ;
}
ATF_TC_BODY ( edns_client_subnet , tc ) {
static void
edns_client_subnet ( void * * state ) {
wire_ok_t wire_ok [ ] = {
/*
* Option code with no content.
@@ -1079,7 +1061,7 @@ ATF_TC_BODY(edns_client_subnet, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( NULL , wire_ok , NULL , true , dns_rdataclass_in ,
dns_rdatatype_opt , sizeof ( dns_rdata_opt_t ) ) ;
@@ -1094,11 +1076,8 @@ ATF_TC_BODY(edns_client_subnet, tc) {
* significant. For readability, whitespace may be included in the value
* field and should be ignored when reading a master file.
*/
ATF_TC ( eid ) ;
ATF_TC_HEAD ( eid , tc ) {
atf_tc_set_md_var ( tc , " descr " , " EID RDATA manipulations " ) ;
}
ATF_TC_BODY ( eid , tc ) {
static void
eid ( void * * state ) {
text_ok_t text_ok [ ] = {
TEXT_VALID ( " AABBCC " ) ,
TEXT_VALID_CHANGED ( " AA bb cc " , " AABBCC " ) ,
@@ -1120,21 +1099,17 @@ ATF_TC_BODY(eid, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , wire_ok , NULL , false , dns_rdataclass_in ,
dns_rdatatype_eid , sizeof ( dns_rdata_in_eid_t ) ) ;
}
/*
* Successful load test.
* test that an oversized HIP record will be rejected
*/
ATF_TC ( hip ) ;
ATF_TC_HEAD ( hip , tc ) {
atf_tc_set_md_var ( tc , " descr " , " that a oversized HIP record will "
" be rejected " ) ;
}
ATF_TC_BODY ( hip , tc ) {
static void
hip ( void * * state ) {
unsigned char hipwire [ DNS_RDATA_MAXLENGTH ] = {
0x01 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 ,
0x04 , 0x41 , 0x42 , 0x43 , 0x44 , 0x00 } ;
@@ -1145,10 +1120,7 @@ ATF_TC_BODY(hip, tc) {
isc_result_t result ;
size_t i ;
UNUSED ( tc ) ;
result = dns_test_begin ( NULL , false ) ;
ATF_REQUIRE_EQ ( result , ISC_R_SUCCESS ) ;
UNUSED ( state ) ;
/*
* Fill the rest of input buffer with compression pointers.
@@ -1168,9 +1140,7 @@ ATF_TC_BODY(hip, tc) {
dns_rdatatype_hip , & source , & dctx ,
0 , & target ) ;
dns_decompress_invalidate ( & dctx ) ;
ATF_REQUIRE_EQ ( result , DNS_R_FORMERR ) ;
dns_test_end ( ) ;
assert_int_equal ( result , DNS_R_FORMERR ) ;
}
/*
@@ -1234,11 +1204,8 @@ ATF_TC_BODY(hip, tc) {
* as one or two <character-string>s, i.e., count followed by
* characters.
*/
ATF_TC ( isdn ) ;
ATF_TC_HEAD ( isdn , tc ) {
atf_tc_set_md_var ( tc , " descr " , " ISDN RDATA manipulations " ) ;
}
ATF_TC_BODY ( isdn , tc ) {
static void
isdn ( void * * state ) {
wire_ok_t wire_ok [ ] = {
/*
* "".
@@ -1262,7 +1229,7 @@ ATF_TC_BODY(isdn, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( NULL , wire_ok , NULL , false , dns_rdataclass_in ,
dns_rdatatype_isdn , sizeof ( dns_rdata_isdn_t ) ) ;
@@ -1277,11 +1244,8 @@ ATF_TC_BODY(isdn, tc) {
* significant. For readability, whitespace may be included in the value
* field and should be ignored when reading a master file.
*/
ATF_TC ( nimloc ) ;
ATF_TC_HEAD ( nimloc , tc ) {
atf_tc_set_md_var ( tc , " descr " , " NIMLOC RDATA manipulations " ) ;
}
ATF_TC_BODY ( nimloc , tc ) {
static void
nimloc ( void * * state ) {
text_ok_t text_ok [ ] = {
TEXT_VALID ( " AABBCC " ) ,
TEXT_VALID_CHANGED ( " AA bb cc " , " AABBCC " ) ,
@@ -1303,7 +1267,7 @@ ATF_TC_BODY(nimloc, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , wire_ok , NULL , false , dns_rdataclass_in ,
dns_rdatatype_nimloc , sizeof ( dns_rdata_in_nimloc_t ) ) ;
@@ -1375,11 +1339,8 @@ ATF_TC_BODY(nimloc, tc) {
* Bits representing pseudo-types MUST be clear, as they do not appear
* in zone data. If encountered, they MUST be ignored upon being read.
*/
ATF_TC ( nsec ) ;
ATF_TC_HEAD ( nsec , tc ) {
atf_tc_set_md_var ( tc , " descr " , " NSEC RDATA manipulations " ) ;
}
ATF_TC_BODY ( nsec , tc ) {
static void
nsec ( void * * state ) {
text_ok_t text_ok [ ] = {
TEXT_INVALID ( " " ) ,
TEXT_INVALID ( " . " ) ,
@@ -1394,7 +1355,7 @@ ATF_TC_BODY(nsec, tc) {
WIRE_INVALID ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , wire_ok , NULL , false , dns_rdataclass_in ,
dns_rdatatype_nsec , sizeof ( dns_rdata_nsec_t ) ) ;
@@ -1405,11 +1366,8 @@ ATF_TC_BODY(nsec, tc) {
*
* RFC 5155.
*/
ATF_TC ( nsec3 ) ;
ATF_TC_HEAD ( nsec3 , tc ) {
atf_tc_set_md_var ( tc , " descr " , " NSEC3 RDATA manipulations " ) ;
}
ATF_TC_BODY ( nsec3 , tc ) {
static void
nsec3 ( void * * state ) {
text_ok_t text_ok [ ] = {
TEXT_INVALID ( " " ) ,
TEXT_INVALID ( " . " ) ,
@@ -1423,20 +1381,15 @@ ATF_TC_BODY(nsec3, tc) {
TEXT_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , NULL , NULL , false , dns_rdataclass_in ,
dns_rdatatype_nsec3 , sizeof ( dns_rdata_nsec3_t ) ) ;
}
/*
* NXT Tests.
*/
ATF_TC ( nxt ) ;
ATF_TC_HEAD ( nxt , tc ) {
atf_tc_set_md_var ( tc , " descr " , " NXT RDATA manipulations " ) ;
}
ATF_TC_BODY ( nxt , tc ) {
/* NXT RDATA manipulations */
static void
nxt ( void * * state ) {
compare_ok_t compare_ok [ ] = {
COMPARE ( " a. A SIG " , " a. A SIG " , 0 ) ,
/*
@@ -1456,7 +1409,7 @@ ATF_TC_BODY(nxt, tc) {
COMPARE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( NULL , NULL , compare_ok , false , dns_rdataclass_in ,
dns_rdatatype_nxt , sizeof ( dns_rdata_nxt_t ) ) ;
@@ -1501,11 +1454,8 @@ ATF_TC_BODY(nxt, tc) {
* port 25; if zero, SMTP service is not supported on the specified
* address.
*/
ATF_TC ( wks ) ;
ATF_TC_HEAD ( wks , tc ) {
atf_tc_set_md_var ( tc , " descr " , " WKS RDATA manipulations " ) ;
}
ATF_TC_BODY ( wks , tc ) {
static void
wks ( void * * state ) {
text_ok_t text_ok [ ] = {
/*
* Valid, IPv4 address in dotted-quad form.
@@ -1543,30 +1493,42 @@ ATF_TC_BODY(wks, tc) {
WIRE_SENTINEL ( )
} ;
UNUSED ( tc ) ;
UNUSED ( state ) ;
check_rdata ( text_ok , wire_ok , NULL , false , dns_rdataclass_in ,
dns_rdatatype_wks , sizeof ( dns_rdata_in_wks_t ) ) ;
}
/*****
***** Main
*****/
int
main ( void ) {
const struct CMUnitTest tests [ ] = {
cmocka_unit_test_setup_teardown ( apl , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( atma , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( csync , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( doa , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( eid , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( edns_client_subnet ,
_setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( hip , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( isdn , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( nimloc , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( nsec , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( nsec3 , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( nxt , _setup , _teardown ) ,
cmocka_unit_test_setup_teardown ( wks , _setup , _teardown ) ,
} ;
ATF_TP_ADD_TCS ( tp ) {
ATF_TP_ADD_TC ( tp , apl ) ;
ATF_TP_ADD_TC ( tp , atma ) ;
ATF_TP_ADD_TC ( tp , csync ) ;
ATF_TP_ADD_TC ( tp , doa ) ;
ATF_TP_ADD_TC ( tp , eid ) ;
ATF_TP_ADD_TC ( tp , edns_client_subnet ) ;
ATF_TP_ADD_TC ( tp , hip ) ;
ATF_TP_ADD_TC ( tp , isdn ) ;
ATF_TP_ADD_TC ( tp , nimloc ) ;
ATF_TP_ADD_TC ( tp , nsec ) ;
ATF_TP_ADD_TC ( tp , nsec3 ) ;
ATF_TP_ADD_TC ( tp , nxt ) ;
ATF_TP_ADD_TC ( tp , wks ) ;
return ( atf_no_error ( ) ) ;
return ( cmocka_run_group_tests ( tests , NULL , NULL ) ) ;
}
# else /* HAVE_CMOCKA */
# include <stdio.h>
int
main ( void ) {
printf ( " 1..0 # Skipped: cmocka not available \n " ) ;
return ( 0 ) ;
}
# endif