|
unbound 0.1
|
Unit test for auth zone code. More...
#include "config.h"#include "services/authzone.h"#include "testcode/unitmain.h"#include "util/regional.h"#include "util/net_help.h"#include "util/config_file.h"#include "util/data/msgreply.h"#include "services/cache/dns.h"#include "sldns/str2wire.h"#include "sldns/wire2str.h"#include "sldns/sbuffer.h"Data Structures | |
| struct | q_ans |
| struct for query and answer checks More... | |
Functions | |
| static void | tmpfilecleanup (void) |
| cleanup tmp files at exit | |
| static char * | create_tmp_file (const char *s) |
| create temp file, return (malloced) name string, write contents to it | |
| static void | del_tmp_file (char *fname) |
| delete temp file and free name string | |
| struct auth_zone * | authtest_addzone (struct auth_zones *az, const char *name, char *fname) |
| Add zone from file for testing. | |
| static void | checkfile (char *f1, char *f2) |
| check that file is the same as other file | |
| static void | check_read_exact (const char *name, const char *zone) |
| check that a zone (in string) can be read and reproduced | |
| static void | q_ans_parse (struct q_ans *q, struct regional *region, struct query_info **qinfo, int *fallback, uint8_t **dp_nm, size_t *dp_nmlen) |
| parse q_ans structure for making query | |
| static void | pr_flags (sldns_buffer *buf, uint16_t flags) |
| print flags to string | |
| static void | pr_rrs (sldns_buffer *buf, struct reply_info *rep) |
| print RRs to string | |
| static char * | msgtostr (struct dns_msg *msg) |
| create string for message | |
| static void | line_diff (const char *p, const char *q, const char *pdesc, const char *qdesc) |
| find line diff between strings | |
| static void | q_ans_query (struct q_ans *q, struct auth_zones *az, struct query_info *qinfo, struct regional *region, int expected_fallback, uint8_t *dp_nm, size_t dp_nmlen) |
| make q_ans query | |
| static void | check_az_q_ans (struct auth_zones *az, struct q_ans *queries) |
| check queries on a loaded zone | |
| static void | check_queries (const char *name, const char *zone, struct q_ans *queries) |
| check queries for a zone are returned as specified | |
| static void | authzone_compare_serial (void) |
| Test authzone compare_serial. | |
| static void | authzone_read_test (void) |
| Test authzone read from file. | |
| static void | authzone_query_test (void) |
| Test authzone query from zone. | |
| static void | authzone_chunkline_count_parens_test (void) |
| Test chunkline_count_parens output. | |
| void | authzone_test (void) |
| test authzone code | |
Variables | |
| static int | vbmp = 0 |
| verbosity for this test | |
| static const char * | zone_example_com |
| auth zone for test | |
| static struct q_ans | example_com_queries [] |
| queries for example.com: zone, query, flags, answer. | |
| static int | tempno = 0 |
| number of tmpfiles | |
| static int | delno = 0 |
| number of deleted files | |
Unit test for auth zone code.
|
static |
cleanup tmp files at exit
References tempno, tmpfilecleanup(), and vbmp.
Referenced by authzone_test(), and tmpfilecleanup().
|
static |
create temp file, return (malloced) name string, write contents to it
References create_tmp_file(), fatal_exit(), and tempno.
Referenced by check_queries(), check_read_exact(), and create_tmp_file().
|
static |
delete temp file and free name string
References del_tmp_file(), delno, and tempno.
Referenced by check_queries(), check_read_exact(), and del_tmp_file().
| struct auth_zone * authtest_addzone | ( | struct auth_zones * | az, |
| const char * | name, | ||
| char * | fname ) |
Add zone from file for testing.
References auth_zone_create(), auth_zone_read_zonefile(), auth_zone_set_zonefile(), authtest_addzone(), config_file::chrootdir, config_auto_slab_values(), config_create(), config_delete(), fatal_exit(), auth_zone::for_upstream, LDNS_RR_CLASS_IN, auth_zone::lock, auth_zones::lock, auth_zone::name, and sldns_str2wire_dname().
Referenced by authtest_addzone(), check_queries(), check_read_exact(), zonemd_check_test(), zonemd_generate_test(), and zonemd_verify_test().
|
static |
check that file is the same as other file
References checkfile(), fatal_exit(), log_info(), and unit_assert.
Referenced by check_read_exact(), and checkfile().
|
static |
check that a zone (in string) can be read and reproduced
References auth_zone_write_file(), auth_zones_create(), auth_zones_delete(), authtest_addzone(), check_read_exact(), checkfile(), create_tmp_file(), del_tmp_file(), fatal_exit(), auth_zone::name, unit_assert, and vbmp.
Referenced by authzone_read_test(), and check_read_exact().
|
static |
parse q_ans structure for making query
References fatal_exit(), q_ans::flags, q_ans_parse(), q_ans::query, regional_alloc_init(), regional_alloc_zero(), sldns_get_errorstr_parse(), sldns_str2wire_dname_buf(), sldns_str2wire_rr_question_buf(), sldns_wirerr_get_class(), sldns_wirerr_get_type(), and q_ans::zone.
Referenced by check_az_q_ans(), and q_ans_parse().
|
static |
print flags to string
References BIT_AA, BIT_AD, BIT_CD, BIT_QR, BIT_RA, BIT_RD, BIT_TC, BIT_Z, FLAGS_GET_RCODE, pr_flags(), and sldns_wire2str_rcode_buf().
Referenced by msgtostr(), and pr_flags().
|
static |
print RRs to string
References reply_info::an_numrrsets, reply_info::ar_numrrsets, packed_rrset_data::count, lruhash_entry::data, ub_packed_rrset_key::entry, fatal_exit(), log_assert, reply_info::ns_numrrsets, packed_rr_to_string(), pr_rrs(), reply_info::rrset_count, reply_info::rrsets, and packed_rrset_data::rrsig_count.
Referenced by msgtostr(), and pr_rrs().
|
static |
create string for message
References fatal_exit(), reply_info::flags, msgtostr(), pr_flags(), pr_rrs(), dns_msg::rep, sldns_buffer_begin(), sldns_buffer_free(), and sldns_buffer_new().
Referenced by msgtostr(), and q_ans_query().
|
static |
find line diff between strings
References fatal_exit(), and line_diff().
Referenced by line_diff(), and q_ans_query().
|
static |
make q_ans query
References q_ans::answer, auth_zones_lookup(), line_diff(), msgtostr(), q_ans_query(), dns_msg::qinfo, unit_assert, vbmp, and verbosity.
Referenced by check_az_q_ans(), and q_ans_query().
|
static |
check queries on a loaded zone
References check_az_q_ans(), q_ans::flags, q_ans_parse(), q_ans_query(), q_ans::query, regional_create(), regional_destroy(), regional_free_all(), vbmp, and q_ans::zone.
Referenced by check_az_q_ans(), and check_queries().
|
static |
check queries for a zone are returned as specified
References auth_zones_create(), auth_zones_delete(), authtest_addzone(), check_az_q_ans(), check_queries(), create_tmp_file(), del_tmp_file(), fatal_exit(), auth_zone::name, and vbmp.
Referenced by authzone_query_test(), and check_queries().
|
static |
Test authzone compare_serial.
References authzone_compare_serial(), unit_assert, and vbmp.
Referenced by authzone_compare_serial(), and authzone_test().
|
static |
Test authzone read from file.
References authzone_read_test(), check_read_exact(), vbmp, and zone_example_com.
Referenced by authzone_read_test(), and authzone_test().
|
static |
Test authzone query from zone.
References authzone_query_test(), check_queries(), example_com_queries, vbmp, and zone_example_com.
Referenced by authzone_query_test(), and authzone_test().
|
static |
Test chunkline_count_parens output.
References authzone_chunkline_count_parens_test(), chunkline_count_parens(), fatal_exit(), sldns_buffer_clear(), sldns_buffer_free(), sldns_buffer_new(), unit_assert, and vbmp.
Referenced by authzone_chunkline_count_parens_test(), and authzone_test().
| void authzone_test | ( | void | ) |
test authzone code
unit test for auth zone functions
test authzone code
References authzone_chunkline_count_parens_test(), authzone_compare_serial(), authzone_query_test(), authzone_read_test(), authzone_test(), tmpfilecleanup(), and unit_show_feature().
Referenced by authzone_test(), and main().
|
static |
verbosity for this test
Referenced by authzone_chunkline_count_parens_test(), authzone_compare_serial(), authzone_query_test(), authzone_read_test(), buf_to_hex(), check_az_q_ans(), check_queries(), check_read_exact(), perftestpkt(), q_ans_query(), rr_checks(), rr_test_file(), rr_transform(), test_buffers(), testfromfile(), testpkt(), and tmpfilecleanup().
|
static |
auth zone for test
Referenced by authzone_query_test(), and authzone_read_test().
|
static |
queries for example.com: zone, query, flags, answer.
end with NULL
Referenced by authzone_query_test().
|
static |
number of tmpfiles
Referenced by create_tmp_file(), del_tmp_file(), and tmpfilecleanup().
|
static |
number of deleted files
Referenced by del_tmp_file().