unbound 0.1
testbound.c File Reference

Exits with code 1 on a failure. More...

#include "config.h"
#include <ctype.h>
#include "testcode/testpkts.h"
#include "testcode/replay.h"
#include "testcode/fake_event.h"
#include "daemon/remote.h"
#include "libunbound/worker.h"
#include "daemon/worker.h"
#include "util/config_file.h"
#include "sldns/keyraw.h"
#include "daemon/unbound.c"

Macros

#define unbound_testbound   1
 signal that this is a testbound compile
#define main   daemon_main
 include the main program from the unbound daemon.
#define MAX_LINE_LEN   1024
 maximum line length for lines in the replay file.
#define MAXARG   100
 Max number of arguments to pass to unbound.

Functions

int daemon_main (int argc, char *argv[])
 renamed main routine
static void testbound_usage (void)
 give commandline usage for testbound.
static void add_opts (const char *args, int *pass_argc, char *pass_argv[])
 Add options from string to passed argc.
static void echo_cmdline (int argc, char *argv[])
 pretty print commandline for unbound in this test
static void spool_temp_file_name (int *lineno, FILE *cfg, char *id)
 spool temp file name
static void spool_temp_file (FILE *in, int *lineno, char *id)
 spool temp file
static void spool_auto_file (FILE *in, int *lineno, FILE *cfg, char *id)
 spool autotrust file
static void setup_config (FILE *in, int *lineno, int *pass_argc, char *pass_argv[])
 process config elements
static struct replay_scenario * setup_playback (const char *filename, int *pass_argc, char *pass_argv[])
 read playback file
static void remove_configfile (void)
 remove config file at exit
static int perform_playback (char *playback_file, int pass_argc, char **pass_argv)
 perform the playback on the playback_file with the args.
int main (int argc, char *argv[])
 Main fake event test program.
struct listen_port * daemon_remote_open_ports (struct config_file *ATTR_UNUSED(cfg))
struct daemon_remote * daemon_remote_create (struct config_file *ATTR_UNUSED(cfg))
void daemon_remote_delete (struct daemon_remote *rc)
 remote control state to delete.
void daemon_remote_clear (struct daemon_remote *ATTR_UNUSED(rc))
int daemon_remote_open_accept (struct daemon_remote *ATTR_UNUSED(rc), struct listen_port *ATTR_UNUSED(ports), struct worker *worker)
int remote_accept_callback (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(repinfo))
int remote_control_callback (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(repinfo))
void remote_get_opt_ssl (char *ATTR_UNUSED(str), void *ATTR_UNUSED(arg))
int tcp_connect_errno_needs_log (struct sockaddr *ATTR_UNUSED(addr), socklen_t ATTR_UNUSED(addrlen))
int squelch_err_ssl_handshake (unsigned long ATTR_UNUSED(err))
void listen_setup_locks (void)
 setup the locks for the listen ports
void listen_desetup_locks (void)
 desetup the locks for the listen ports
void fast_reload_printq_list_delete (struct fast_reload_printq *ATTR_UNUSED(list))
void fast_reload_worker_pickup_changes (struct worker *ATTR_UNUSED(worker))
void tcp_read_again_cb (void *ATTR_UNUSED(arg))
void tcp_more_read_again_cb (void *ATTR_UNUSED(arg))

Variables

static struct config_strlist * cfgfiles = NULL
 config files (removed at exit)

Detailed Description

Exits with code 1 on a failure.

0 if all unit tests are successful.

Macro Definition Documentation

◆ main

#define main   daemon_main

include the main program from the unbound daemon.

rename main to daemon_main to call it

Referenced by main(), main(), and main().

◆ MAXARG

#define MAXARG   100

Max number of arguments to pass to unbound.

Referenced by add_opts(), and main().

Function Documentation

◆ daemon_main()

int daemon_main ( int argc,
char * argv[] )

renamed main routine

References daemon_main().

Referenced by daemon_main(), and perform_playback().

◆ testbound_usage()

void testbound_usage ( void )
static

give commandline usage for testbound.

References testbound_usage().

Referenced by main(), and testbound_usage().

◆ add_opts()

void add_opts ( const char * args,
int * pass_argc,
char * pass_argv[] )
static

Add options from string to passed argc.

splits on whitespace.

Parameters
argsthe option argument, "-v -p 12345" or so.
pass_argcptr to the argc for unbound. Modified.
pass_argvthe argv to pass to unbound. Modified.

References add_opts(), fatal_exit(), and MAXARG.

Referenced by add_opts(), main(), and setup_config().

◆ echo_cmdline()

void echo_cmdline ( int argc,
char * argv[] )
static

pretty print commandline for unbound in this test

References echo_cmdline().

Referenced by echo_cmdline(), and perform_playback().

◆ spool_temp_file_name()

void spool_temp_file_name ( int * lineno,
FILE * cfg,
char * id )
static

◆ spool_temp_file()

void spool_temp_file ( FILE * in,
int * lineno,
char * id )
static

◆ spool_auto_file()

void spool_auto_file ( FILE * in,
int * lineno,
FILE * cfg,
char * id )
static

◆ setup_config()

void setup_config ( FILE * in,
int * lineno,
int * pass_argc,
char * pass_argv[] )
static

◆ setup_playback()

struct replay_scenario * setup_playback ( const char * filename,
int * pass_argc,
char * pass_argv[] )
static

◆ remove_configfile()

void remove_configfile ( void )
static

remove config file at exit

References cfgfiles, config_delstrlist(), config_strlist::next, remove_configfile(), and config_strlist::str.

Referenced by main(), and remove_configfile().

◆ perform_playback()

int perform_playback ( char * playback_file,
int pass_argc,
char ** pass_argv )
static

perform the playback on the playback_file with the args.

References daemon_main(), echo_cmdline(), fake_event_cleanup(), fake_event_init(), perform_playback(), and setup_playback().

Referenced by main(), and perform_playback().

◆ main()

int main ( int argc,
char * argv[] )

Main fake event test program.

Setup, teardown and report errors.

Parameters
argcarg count.
argvarray of commandline arguments.
Returns
program failure if test fails.

References add_opts(), fatal_exit(), log_get_lock(), log_info(), log_init(), main, MAXARG, optarg, optind, perform_playback(), remove_configfile(), testbound_selftest(), and testbound_usage().

◆ daemon_remote_delete()

void daemon_remote_delete ( struct daemon_remote * rc)

remote control state to delete.

Parameters
rcstate to delete.

References daemon_remote_delete().

◆ listen_setup_locks()

void listen_setup_locks ( void )

setup the locks for the listen ports

References listen_setup_locks().

◆ listen_desetup_locks()

void listen_desetup_locks ( void )

desetup the locks for the listen ports

References listen_desetup_locks().

Variable Documentation

◆ cfgfiles

struct config_strlist* cfgfiles = NULL
static

config files (removed at exit)

Referenced by remove_configfile(), setup_config(), spool_auto_file(), and spool_temp_file().