unbound 0.1
unitldns.c File Reference

Calls ldns unit tests. More...

#include "config.h"
#include "util/log.h"
#include "testcode/unitmain.h"
#include "sldns/sbuffer.h"
#include "sldns/str2wire.h"
#include "sldns/wire2str.h"
#include "sldns/parseutil.h"

Macros

#define xstr(s)
#define str(s)
#define SRCDIRSTR   xstr(SRCDIR)

Functions

static void buf_to_hex (uint8_t *b, size_t blen, char *s, size_t slen)
 print buffer to hex into string
static void rr_transform (char *txt_in, char *wire1, char *txt_out, char *wire2, size_t bufs)
 Transform input.
static void rr_checks (char *wire_chk, char *txt_chk, char *txt_out, char *wire_out, char *back)
 Check if results are correct.
static void rr_test_file (const char *input, const char *check)
 read rrs to and from string, and wireformat Skips empty lines and comments.
static void rr_tests (void)
 read rrs to and from string, to and from wireformat
static void b64_test (void)
 test various base64 decoding options
static void svcb_ech_test (void)
 test SVCB ech svcparam
void ldns_test (void)
 unit test for ldns functions

Variables

static int vbmp = 0
 verbose this unit test

Detailed Description

Calls ldns unit tests.

Exits with code 1 on a failure.

Macro Definition Documentation

◆ xstr

#define xstr ( s)
Value:
str(s)

◆ str

#define str ( s)
Value:
#s

Function Documentation

◆ buf_to_hex()

void buf_to_hex ( uint8_t * b,
size_t blen,
char * s,
size_t slen )
static

print buffer to hex into string

References buf_to_hex(), unit_assert, and vbmp.

Referenced by buf_to_hex(), and rr_transform().

◆ rr_transform()

void rr_transform ( char * txt_in,
char * wire1,
char * txt_out,
char * wire2,
size_t bufs )
static

Transform input.

Parameters
txt_ininput text format.
wire1output wireformat in hex (txt_in converted to wire).
txt_outoutput text format (converted from wire_out).
wire2output wireformat in hex, txt_out converted back to wireformat.
bufssize of the text buffers.

References buf_to_hex(), rr_transform(), sldns_get_errorstr_parse(), sldns_str2wire_rr_buf(), sldns_wire2str_rr_buf(), unit_assert, and vbmp.

Referenced by rr_test_file(), and rr_transform().

◆ rr_checks()

void rr_checks ( char * wire_chk,
char * txt_chk,
char * txt_out,
char * wire_out,
char * back )
static

Check if results are correct.

References rr_checks(), unit_assert, and vbmp.

Referenced by rr_checks(), and rr_test_file().

◆ rr_test_file()

void rr_test_file ( const char * input,
const char * check )
static

read rrs to and from string, and wireformat Skips empty lines and comments.

Parameters
inputinput file with text format.
checkcheck file with hex and then textformat

References fatal_exit(), rr_checks(), rr_test_file(), rr_transform(), unit_assert, and vbmp.

Referenced by rr_test_file(), and rr_tests().

◆ rr_tests()

void rr_tests ( void )
static

read rrs to and from string, to and from wireformat

References rr_test_file(), and rr_tests().

Referenced by ldns_test(), and rr_tests().

◆ b64_test()

void b64_test ( void )
static

test various base64 decoding options

References b64_test(), and unit_assert.

Referenced by b64_test(), and ldns_test().

◆ svcb_ech_test()

void svcb_ech_test ( void )
static

test SVCB ech svcparam

References LDNS_RR_BUF_SIZE, sldns_str2wire_rr_buf(), svcb_ech_test(), and unit_assert.

Referenced by ldns_test(), and svcb_ech_test().

◆ ldns_test()

void ldns_test ( void )

unit test for ldns functions

References b64_test(), ldns_test(), rr_tests(), svcb_ech_test(), and unit_show_feature().

Referenced by ldns_test(), and main().