unitauth.c File Reference

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...


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_zoneauthtest_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.
void authzone_test (void)
 test authzone code More...


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. More...
static int tempno = 0
 number of tmpfiles
static int delno = 0
 number of deleted files

Detailed Description

Unit test for auth zone code.

Function Documentation

◆ authzone_test()

void authzone_test ( void  )

test authzone code

unit test for auth zone functions

References authzone_compare_serial(), authzone_query_test(), authzone_read_test(), tmpfilecleanup(), and unit_show_feature().

Variable Documentation

◆ example_com_queries

struct q_ans example_com_queries[]

queries for example.com: zone, query, flags, answer.

end with NULL

Referenced by authzone_query_test().