summaryrefslogtreecommitdiff
path: root/tests/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/cli/common_cli.c9
-rw-r--r--tests/lib/cli/test_commands.c146
-rw-r--r--tests/lib/northbound/test_oper_data.c9
-rw-r--r--tests/lib/test_checksum.c3
-rw-r--r--tests/lib/test_segv.c6
-rw-r--r--tests/lib/test_sig.c6
-rw-r--r--tests/lib/test_srcdest_table.c5
-rw-r--r--tests/lib/test_zlog.c7
8 files changed, 119 insertions, 72 deletions
diff --git a/tests/lib/cli/common_cli.c b/tests/lib/cli/common_cli.c
index e091372ab8..3cade4a2c9 100644
--- a/tests/lib/cli/common_cli.c
+++ b/tests/lib/cli/common_cli.c
@@ -53,7 +53,6 @@ static void vty_do_exit(int isexit)
nb_terminate();
yang_terminate();
thread_master_free(master);
- closezlog();
log_memstats(stderr, "testcli");
if (!isexit)
@@ -71,11 +70,7 @@ int main(int argc, char **argv)
/* master init. */
master = thread_master_create(NULL);
- openzlog("common-cli", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID,
- LOG_DAEMON);
- zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
- zlog_set_level(ZLOG_DEST_STDOUT, ZLOG_DISABLED);
- zlog_set_level(ZLOG_DEST_MONITOR, LOG_DEBUG);
+ zlog_aux_init("NONE: ", ZLOG_DISABLED);
/* Library inits. */
cmd_init(1);
@@ -84,7 +79,7 @@ int main(int argc, char **argv)
vty_init(master, false);
lib_cmd_init();
- yang_init();
+ yang_init(true);
nb_init(master, NULL, 0);
test_init(argc, argv);
diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c
index bbdc8b238d..2b345c91e8 100644
--- a/tests/lib/cli/test_commands.c
+++ b/tests/lib/cli/test_commands.c
@@ -49,50 +49,116 @@ static vector test_cmds;
static char test_buf[32768];
static struct cmd_node bgp_node = {
- BGP_NODE, "%s(config-router)# ",
+ .name = "bgp",
+ .node = BGP_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-router)# ",
};
static struct cmd_node rip_node = {
- RIP_NODE, "%s(config-router)# ",
+ .name = "rip",
+ .node = RIP_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-router)# ",
};
static struct cmd_node isis_node = {
- ISIS_NODE, "%s(config-router)# ",
+ .name = "isis",
+ .node = ISIS_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-router)# ",
};
static struct cmd_node interface_node = {
- INTERFACE_NODE, "%s(config-if)# ",
+ .name = "interface",
+ .node = INTERFACE_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-if)# ",
};
-static struct cmd_node rmap_node = {RMAP_NODE, "%s(config-route-map)# "};
+static struct cmd_node rmap_node = {
+ .name = "routemap",
+ .node = RMAP_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-route-map)# ",
+};
-static struct cmd_node zebra_node = {ZEBRA_NODE, "%s(config-router)# "};
+static struct cmd_node zebra_node = {
+ .name = "zebra",
+ .node = ZEBRA_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-router)# ",
+};
-static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE,
- "%s(config-router-af)# "};
+static struct cmd_node bgp_vpnv4_node = {
+ .name = "bgp vpnv4",
+ .node = BGP_VPNV4_NODE,
+ .parent_node = BGP_NODE,
+ .prompt = "%s(config-router-af)# ",
+};
-static struct cmd_node bgp_ipv4_node = {BGP_IPV4_NODE,
- "%s(config-router-af)# "};
+static struct cmd_node bgp_ipv4_node = {
+ .name = "bgp ipv4 unicast",
+ .node = BGP_IPV4_NODE,
+ .parent_node = BGP_NODE,
+ .prompt = "%s(config-router-af)# ",
+};
-static struct cmd_node bgp_ipv4m_node = {BGP_IPV4M_NODE,
- "%s(config-router-af)# "};
+static struct cmd_node bgp_ipv4m_node = {
+ .name = "bgp ipv4 multicast",
+ .node = BGP_IPV4M_NODE,
+ .parent_node = BGP_NODE,
+ .prompt = "%s(config-router-af)# ",
+};
-static struct cmd_node bgp_ipv6_node = {BGP_IPV6_NODE,
- "%s(config-router-af)# "};
+static struct cmd_node bgp_ipv6_node = {
+ .name = "bgp ipv6",
+ .node = BGP_IPV6_NODE,
+ .parent_node = BGP_NODE,
+ .prompt = "%s(config-router-af)# ",
+};
-static struct cmd_node bgp_ipv6m_node = {BGP_IPV6M_NODE,
- "%s(config-router-af)# "};
+static struct cmd_node bgp_ipv6m_node = {
+ .name = "bgp ipv6 multicast",
+ .node = BGP_IPV6M_NODE,
+ .parent_node = BGP_NODE,
+ .prompt = "%s(config-router-af)# ",
+};
-static struct cmd_node ospf_node = {OSPF_NODE, "%s(config-router)# "};
+static struct cmd_node ospf_node = {
+ .name = "ospf",
+ .node = OSPF_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-router)# ",
+};
-static struct cmd_node ripng_node = {RIPNG_NODE, "%s(config-router)# "};
+static struct cmd_node ripng_node = {
+ .name = "ripng",
+ .node = RIPNG_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-router)# ",
+};
-static struct cmd_node ospf6_node = {OSPF6_NODE, "%s(config-ospf6)# "};
+static struct cmd_node ospf6_node = {
+ .name = "ospf6",
+ .node = OSPF6_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-ospf6)# ",
+};
-static struct cmd_node keychain_node = {KEYCHAIN_NODE, "%s(config-keychain)# "};
+static struct cmd_node keychain_node = {
+ .name = "keychain",
+ .node = KEYCHAIN_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-keychain)# ",
+};
-static struct cmd_node keychain_key_node = {KEYCHAIN_KEY_NODE,
- "%s(config-keychain-key)# "};
+static struct cmd_node keychain_key_node = {
+ .name = "keychain key",
+ .node = KEYCHAIN_KEY_NODE,
+ .parent_node = KEYCHAIN_NODE,
+ .prompt = "%s(config-keychain-key)# ",
+};
static int test_callback(const struct cmd_element *cmd, struct vty *vty,
int argc, struct cmd_token *argv[])
@@ -142,26 +208,26 @@ static void test_init(void)
struct cmd_element *cmd;
cmd_init(1);
- yang_init();
+ yang_init(true);
nb_init(master, NULL, 0);
- install_node(&bgp_node, NULL);
- install_node(&rip_node, NULL);
- install_node(&interface_node, NULL);
- install_node(&rmap_node, NULL);
- install_node(&zebra_node, NULL);
- install_node(&bgp_vpnv4_node, NULL);
- install_node(&bgp_ipv4_node, NULL);
- install_node(&bgp_ipv4m_node, NULL);
- install_node(&bgp_ipv6_node, NULL);
- install_node(&bgp_ipv6m_node, NULL);
- install_node(&ospf_node, NULL);
- install_node(&ripng_node, NULL);
- install_node(&ospf6_node, NULL);
- install_node(&keychain_node, NULL);
- install_node(&keychain_key_node, NULL);
- install_node(&isis_node, NULL);
- install_node(&vty_node, NULL);
+ install_node(&bgp_node);
+ install_node(&rip_node);
+ install_node(&interface_node);
+ install_node(&rmap_node);
+ install_node(&zebra_node);
+ install_node(&bgp_vpnv4_node);
+ install_node(&bgp_ipv4_node);
+ install_node(&bgp_ipv4m_node);
+ install_node(&bgp_ipv6_node);
+ install_node(&bgp_ipv6m_node);
+ install_node(&ospf_node);
+ install_node(&ripng_node);
+ install_node(&ospf6_node);
+ install_node(&keychain_node);
+ install_node(&keychain_key_node);
+ install_node(&isis_node);
+ install_node(&vty_node);
test_init_cmd();
diff --git a/tests/lib/northbound/test_oper_data.c b/tests/lib/northbound/test_oper_data.c
index 18d3180889..e16412986e 100644
--- a/tests/lib/northbound/test_oper_data.c
+++ b/tests/lib/northbound/test_oper_data.c
@@ -374,7 +374,6 @@ static void vty_do_exit(int isexit)
nb_terminate();
yang_terminate();
thread_master_free(master);
- closezlog();
log_memstats(stderr, "test-nb-oper-data");
if (!isexit)
@@ -402,18 +401,14 @@ int main(int argc, char **argv)
/* master init. */
master = thread_master_create(NULL);
- openzlog("test-nb-oper-data", "NONE", 0,
- LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
- zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
- zlog_set_level(ZLOG_DEST_STDOUT, ZLOG_DISABLED);
- zlog_set_level(ZLOG_DEST_MONITOR, LOG_DEBUG);
+ zlog_aux_init("NONE: ", ZLOG_DISABLED);
/* Library inits. */
cmd_init(1);
cmd_hostname_set("test");
vty_init(master, false);
lib_cmd_init();
- yang_init();
+ yang_init(true);
nb_init(master, modules, array_size(modules));
/* Create artificial data. */
diff --git a/tests/lib/test_checksum.c b/tests/lib/test_checksum.c
index 13d35b0e99..ddb76c8f9d 100644
--- a/tests/lib/test_checksum.c
+++ b/tests/lib/test_checksum.c
@@ -23,6 +23,7 @@
#include <time.h>
#include "checksum.h"
+#include "network.h"
struct thread_master *master;
@@ -477,7 +478,7 @@ int main(int argc, char **argv)
exercise %= MAXDATALEN;
for (i = 0; i < exercise; i += sizeof(long int)) {
- long int rand = random();
+ long int rand = frr_weak_random();
for (j = sizeof(long int); j > 0; j--)
buffer[i + (sizeof(long int) - j)] =
diff --git a/tests/lib/test_segv.c b/tests/lib/test_segv.c
index 43ca0837d5..8133637adc 100644
--- a/tests/lib/test_segv.c
+++ b/tests/lib/test_segv.c
@@ -73,11 +73,7 @@ int main(void)
master = thread_master_create(NULL);
signal_init(master, array_size(sigs), sigs);
- openzlog("testsegv", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID,
- LOG_DAEMON);
- zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
- zlog_set_level(ZLOG_DEST_STDOUT, LOG_DEBUG);
- zlog_set_level(ZLOG_DEST_MONITOR, ZLOG_DISABLED);
+ zlog_aux_init("NONE: ", LOG_DEBUG);
thread_execute(master, threadfunc, 0, 0);
diff --git a/tests/lib/test_sig.c b/tests/lib/test_sig.c
index cf63a3d047..2aceafb8f0 100644
--- a/tests/lib/test_sig.c
+++ b/tests/lib/test_sig.c
@@ -57,11 +57,7 @@ int main(void)
master = thread_master_create(NULL);
signal_init(master, array_size(sigs), sigs);
- openzlog("testsig", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID,
- LOG_DAEMON);
- zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
- zlog_set_level(ZLOG_DEST_STDOUT, LOG_DEBUG);
- zlog_set_level(ZLOG_DEST_MONITOR, ZLOG_DISABLED);
+ zlog_aux_init("NONE: ", LOG_DEBUG);
while (thread_fetch(master, &t))
thread_call(&t);
diff --git a/tests/lib/test_srcdest_table.c b/tests/lib/test_srcdest_table.c
index 0fca571d28..9d395bee89 100644
--- a/tests/lib/test_srcdest_table.c
+++ b/tests/lib/test_srcdest_table.c
@@ -4,7 +4,7 @@
* Copyright (C) 2017 by David Lamparter & Christian Franke,
* Open Source Routing / NetDEF Inc.
*
- * This file is part of FreeRangeRouting (FRR)
+ * This file is part of FRRouting (FRR)
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -391,8 +391,7 @@ static void test_state_del_one_route(struct test_state *test, struct prng *prng)
}
assert(rn);
- srcdest_rnode_prefixes(rn, (const struct prefix **)&dst_p,
- (const struct prefix **)&src_p);
+ srcdest_rnode_prefixes(rn, &dst_p, &src_p);
memcpy(&dst6_p, dst_p, sizeof(dst6_p));
if (src_p)
memcpy(&src6_p, src_p, sizeof(src6_p));
diff --git a/tests/lib/test_zlog.c b/tests/lib/test_zlog.c
index 07885d9847..48fa7bce94 100644
--- a/tests/lib/test_zlog.c
+++ b/tests/lib/test_zlog.c
@@ -20,6 +20,7 @@
#include <zebra.h>
#include <memory.h>
#include "log.h"
+#include "network.h"
/* maximum amount of data to hexdump */
#define MAXDATA 16384
@@ -37,7 +38,7 @@ static bool test_zlog_hexdump(void)
uint8_t d[nl];
for (unsigned int i = 0; i < nl; i++)
- d[i] = random();
+ d[i] = frr_weak_random();
zlog_hexdump(d, nl - 1);
nl += 1 + (nl / 2);
@@ -52,9 +53,7 @@ bool (*tests[])(void) = {
int main(int argc, char **argv)
{
- openzlog("testzlog", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID,
- LOG_ERR);
- zlog_set_file("test_zlog.log", LOG_DEBUG);
+ zlog_aux_init("NONE: ", ZLOG_DISABLED);
for (unsigned int i = 0; i < array_size(tests); i++)
if (!tests[i]())