From dd93d455c165fe89ae133cf7ed8475ed85c5711f Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Tue, 26 Oct 1999 01:53:45 +0000 Subject: [PATCH] fix tests --- bin/tests/rbt/dns_rbtnodechain_first_1.data | 2 +- bin/tests/rbt/dns_rbtnodechain_first_data | 2 +- bin/tests/rbt/t_rbt.c | 63 ++++++++++++++------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/bin/tests/rbt/dns_rbtnodechain_first_1.data b/bin/tests/rbt/dns_rbtnodechain_first_1.data index 1e0bfc9c0a..85bd8c2e18 100644 --- a/bin/tests/rbt/dns_rbtnodechain_first_1.data +++ b/bin/tests/rbt/dns_rbtnodechain_first_1.data @@ -1,4 +1,4 @@ -vix.com +b.com a.vix.com b.vix.com c.vix.com diff --git a/bin/tests/rbt/dns_rbtnodechain_first_data b/bin/tests/rbt/dns_rbtnodechain_first_data index 6d5bca1cfc..10201e40e6 100644 --- a/bin/tests/rbt/dns_rbtnodechain_first_data +++ b/bin/tests/rbt/dns_rbtnodechain_first_data @@ -3,5 +3,5 @@ # # format is: # -dns_rbtnodechain_first_1.data . . . . +dns_rbtnodechain_first_1.data . . com . dns_rbtnodechain_first_2.data . . vix.com . diff --git a/bin/tests/rbt/t_rbt.c b/bin/tests/rbt/t_rbt.c index dde7674ea3..9b340671d6 100644 --- a/bin/tests/rbt/t_rbt.c +++ b/bin/tests/rbt/t_rbt.c @@ -47,7 +47,8 @@ static char *fixedname_totext(dns_fixedname_t *name); static int fixedname_cmp(dns_fixedname_t *dns_name, char *txtname); static char *dnsname_totext(dns_name_t *name); static int t_namechk(dns_result_t dns_result, dns_fixedname_t *dns_name, char *exp_name, - dns_fixedname_t *dns_origin, char *exp_origin); + dns_fixedname_t *dns_origin, char *exp_origin, + dns_result_t exp_result); /* parts adapted from the original rbt_test.c */ @@ -680,8 +681,9 @@ t9_walkchain(dns_rbtnodechain_t *chain, dns_rbt_t *rbt) { static int t_namechk(dns_result_t dns_result, dns_fixedname_t *dns_name, char *exp_name, - dns_fixedname_t *dns_origin, char *exp_origin) { - + dns_fixedname_t *dns_origin, char *exp_origin, + dns_result_t exp_result) +{ int nfails; nfails = 0; @@ -693,15 +695,14 @@ t_namechk(dns_result_t dns_result, dns_fixedname_t *dns_name, char *exp_name, } if (exp_origin != NULL) { t_info("checking for DNS_R_NEWORIGIN\n"); - if (dns_result == DNS_R_NEWORIGIN) { + if (dns_result == exp_result) { if (fixedname_cmp(dns_origin, exp_origin)) { - t_info("\tnew origin %s, expected %s\n", - fixedname_totext(dns_origin), - exp_origin); + t_info("\torigin %s, expected %s\n", + fixedname_totext(dns_origin), + exp_origin); ++nfails; } - } - else { + } else { t_info("\tgot %s\n", dns_result_totext(dns_result)); ++nfails; } @@ -776,6 +777,7 @@ t_dns_rbtnodechain_init(char *dbfile, char *findname, } /* set the starting node */ + node = NULL; dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname), dns_fixedname_name(&dns_foundname), &node, &chain, ISC_TRUE, NULL, NULL); @@ -797,7 +799,8 @@ t_dns_rbtnodechain_init(char *dbfile, char *findname, dns_result_totext(dns_result)); } - nfails += t_namechk(dns_result, &dns_nextname, nextname, &dns_origin, nextorigin); + nfails += t_namechk(dns_result, &dns_nextname, nextname, &dns_origin, nextorigin, + DNS_R_NEWORIGIN); /* set the starting node again */ node = NULL; @@ -823,7 +826,8 @@ t_dns_rbtnodechain_init(char *dbfile, char *findname, t_info("dns_rbtnodechain_prev unexpectedly returned %s\n", dns_result_totext(dns_result)); } - nfails += t_namechk(dns_result, &dns_prevname, prevname, &dns_origin, prevorigin); + nfails += t_namechk(dns_result, &dns_prevname, prevname, &dns_origin, prevorigin, + DNS_R_NEWORIGIN); /* check first */ @@ -837,7 +841,8 @@ t_dns_rbtnodechain_init(char *dbfile, char *findname, t_info("dns_rbtnodechain_first unexpectedly returned %s\n", dns_result_totext(dns_result)); } - nfails += t_namechk(dns_result, &dns_firstname, firstname, &dns_origin, firstorigin); + nfails += t_namechk(dns_result, &dns_firstname, firstname, &dns_origin, firstorigin, + DNS_R_NEWORIGIN); /* check last */ @@ -850,7 +855,8 @@ t_dns_rbtnodechain_init(char *dbfile, char *findname, t_info("dns_rbtnodechain_last unexpectedly returned %s\n", dns_result_totext(dns_result)); } - nfails += t_namechk(dns_result, &dns_lastname, lastname, &dns_origin, lastorigin); + nfails += t_namechk(dns_result, &dns_lastname, lastname, &dns_origin, lastorigin, + DNS_R_NEWORIGIN); /* check node ordering */ t_info("checking node ordering\n"); @@ -960,6 +966,7 @@ t_dns_rbtnodechain_first(char *dbfile, char *expected_firstname, dns_result_t dns_result; dns_fixedname_t dns_name; dns_fixedname_t dns_origin; + dns_result_t expected_result; result = T_UNRESOLVED; @@ -995,10 +1002,10 @@ t_dns_rbtnodechain_first(char *dbfile, char *expected_firstname, t_info("dns_rbtnodechain_first unexpectedly returned %s\n", dns_result_totext(dns_result)); } - nfails = t_namechk(dns_result, &dns_name, expected_firstname, &dns_origin, expected_firstorigin); + nfails = t_namechk(dns_result, &dns_name, expected_firstname, + &dns_origin, expected_firstorigin, DNS_R_NEWORIGIN); dns_fixedname_init(&dns_name); - dns_fixedname_init(&dns_origin); dns_result = dns_rbtnodechain_next(&chain, dns_fixedname_name(&dns_name), dns_fixedname_name(&dns_origin)); @@ -1010,7 +1017,12 @@ t_dns_rbtnodechain_first(char *dbfile, char *expected_firstname, t_info("dns_rbtnodechain_next unexpectedly returned %s\n", dns_result_totext(dns_result)); } - nfails += t_namechk(dns_result, &dns_name, expected_nextname, &dns_origin, expected_nextorigin); + if (strcasecmp(expected_firstorigin, expected_nextorigin) == 0) + expected_result = DNS_R_SUCCESS; + else + expected_result = DNS_R_NEWORIGIN; + nfails += t_namechk(dns_result, &dns_name, expected_nextname, + &dns_origin, expected_nextorigin, expected_result); if (nfails) result = T_FAIL; @@ -1116,6 +1128,7 @@ t_dns_rbtnodechain_last(char *dbfile, char *expected_lastname, dns_result_t dns_result; dns_fixedname_t dns_name; dns_fixedname_t dns_origin; + dns_result_t expected_result; result = T_UNRESOLVED; @@ -1150,12 +1163,12 @@ t_dns_rbtnodechain_last(char *dbfile, char *expected_lastname, t_info("dns_rbtnodechain_last unexpectedly returned %s\n", dns_result_totext(dns_result)); } - nfails = t_namechk(dns_result, &dns_name, expected_lastname, &dns_origin, expected_lastorigin); + nfails = t_namechk(dns_result, &dns_name, expected_lastname, &dns_origin, expected_lastorigin, + DNS_R_NEWORIGIN); t_info("testing for previous name of %s, origin of %s\n", expected_prevname, expected_prevorigin); dns_fixedname_init(&dns_name); - dns_fixedname_init(&dns_origin); dns_result = dns_rbtnodechain_prev(&chain, dns_fixedname_name(&dns_name), dns_fixedname_name(&dns_origin)); @@ -1164,7 +1177,12 @@ t_dns_rbtnodechain_last(char *dbfile, char *expected_lastname, t_info("dns_rbtnodechain_prev unexpectedly returned %s\n", dns_result_totext(dns_result)); } - nfails += t_namechk(dns_result, &dns_name, expected_prevname, &dns_origin, expected_prevorigin); + if (strcasecmp(expected_lastorigin, expected_prevorigin) == 0) + expected_result = DNS_R_SUCCESS; + else + expected_result = DNS_R_NEWORIGIN; + nfails += t_namechk(dns_result, &dns_name, expected_prevname, + &dns_origin, expected_prevorigin, expected_result); if (nfails) result = T_FAIL; @@ -1313,6 +1331,7 @@ t_dns_rbtnodechain_next(char *dbfile, char *findname, } /* set the starting node */ + node = NULL; dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname), dns_fixedname_name(&dns_foundname), &node, &chain, ISC_TRUE, NULL, NULL); @@ -1334,7 +1353,8 @@ t_dns_rbtnodechain_next(char *dbfile, char *findname, dns_result_totext(dns_result)); } - nfails += t_namechk(dns_result, &dns_nextname, nextname, &dns_origin, nextorigin); + nfails += t_namechk(dns_result, &dns_nextname, nextname, &dns_origin, nextorigin, + DNS_R_NEWORIGIN); if (nfails) result = T_FAIL; @@ -1504,7 +1524,8 @@ t_dns_rbtnodechain_prev(char *dbfile, char *findname, dns_result_totext(dns_result)); } - nfails += t_namechk(dns_result, &dns_prevname, prevname, &dns_origin, prevorigin); + nfails += t_namechk(dns_result, &dns_prevname, prevname, &dns_origin, prevorigin, + DNS_R_NEWORIGIN); if (nfails) result = T_FAIL;