summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/bgpd/test_capability.c2
-rw-r--r--tests/bgpd/test_mp_attr.c2
-rw-r--r--tests/bgpd/test_packet.c2
-rw-r--r--tests/helpers/c/main.c4
-rw-r--r--tests/lib/cli/common_cli.c4
-rw-r--r--tests/lib/cxxcompat.c2
-rw-r--r--tests/lib/northbound/test_oper_data.c4
-rw-r--r--tests/lib/test_buffer.c4
-rw-r--r--tests/lib/test_privs.c4
-rw-r--r--tests/lib/test_versioncmp.c66
-rw-r--r--tests/lib/test_versioncmp.py6
-rw-r--r--tests/subdir.am6
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py6
-rw-r--r--tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py23
-rw-r--r--tests/topotests/lib/common_config.py13
16 files changed, 131 insertions, 18 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 6252cea823..5414cb8cc9 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -45,6 +45,7 @@
/lib/test_timer_performance
/lib/test_ttable
/lib/test_typelist
+/lib/test_versioncmp
/lib/test_zlog
/lib/test_zmq
/ospf6d/test_lsdb
diff --git a/tests/bgpd/test_capability.c b/tests/bgpd/test_capability.c
index 96e398512b..1b3f90434b 100644
--- a/tests/bgpd/test_capability.c
+++ b/tests/bgpd/test_capability.c
@@ -923,7 +923,7 @@ int main(void)
if (fileno(stdout) >= 0)
tty = isatty(fileno(stdout));
- if (bgp_get(&bgp, &asn, NULL, BGP_INSTANCE_TYPE_DEFAULT))
+ if (bgp_get(&bgp, &asn, NULL, BGP_INSTANCE_TYPE_DEFAULT) < 0)
return -1;
peer = peer_create_accept(bgp);
diff --git a/tests/bgpd/test_mp_attr.c b/tests/bgpd/test_mp_attr.c
index fbf2a9fed2..af9e5791b7 100644
--- a/tests/bgpd/test_mp_attr.c
+++ b/tests/bgpd/test_mp_attr.c
@@ -1087,7 +1087,7 @@ int main(void)
if (fileno(stdout) >= 0)
tty = isatty(fileno(stdout));
- if (bgp_get(&bgp, &asn, NULL, BGP_INSTANCE_TYPE_DEFAULT))
+ if (bgp_get(&bgp, &asn, NULL, BGP_INSTANCE_TYPE_DEFAULT) < 0)
return -1;
peer = peer_create_accept(bgp);
diff --git a/tests/bgpd/test_packet.c b/tests/bgpd/test_packet.c
index 7a038fb02e..d2c093fbea 100644
--- a/tests/bgpd/test_packet.c
+++ b/tests/bgpd/test_packet.c
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
vrf_init(NULL, NULL, NULL, NULL, NULL);
bgp_option_set(BGP_OPT_NO_LISTEN);
- if (bgp_get(&bgp, &asn, NULL, BGP_INSTANCE_TYPE_DEFAULT))
+ if (bgp_get(&bgp, &asn, NULL, BGP_INSTANCE_TYPE_DEFAULT) < 0)
return -1;
peer = peer_create_accept(bgp);
diff --git a/tests/helpers/c/main.c b/tests/helpers/c/main.c
index b1dcfcf707..2de29cbdbc 100644
--- a/tests/helpers/c/main.c
+++ b/tests/helpers/c/main.c
@@ -24,7 +24,7 @@
#include "vty.h"
#include "command.h"
#include "memory.h"
-#include "memory_vty.h"
+#include "lib_vty.h"
extern void test_init(void);
@@ -154,7 +154,7 @@ int main(int argc, char **argv)
/* Library inits. */
cmd_init(1);
vty_init(master, false);
- memory_init();
+ lib_cmd_init();
yang_init();
nb_init(master, NULL, 0);
diff --git a/tests/lib/cli/common_cli.c b/tests/lib/cli/common_cli.c
index 2071ae08cd..e091372ab8 100644
--- a/tests/lib/cli/common_cli.c
+++ b/tests/lib/cli/common_cli.c
@@ -25,7 +25,7 @@
#include "vty.h"
#include "command.h"
#include "memory.h"
-#include "memory_vty.h"
+#include "lib_vty.h"
#include "log.h"
#include "common_cli.h"
@@ -83,7 +83,7 @@ int main(int argc, char **argv)
cmd_domainname_set("test.domain");
vty_init(master, false);
- memory_init();
+ lib_cmd_init();
yang_init();
nb_init(master, NULL, 0);
diff --git a/tests/lib/cxxcompat.c b/tests/lib/cxxcompat.c
index 88126e84bc..391ccd9268 100644
--- a/tests/lib/cxxcompat.c
+++ b/tests/lib/cxxcompat.c
@@ -51,13 +51,13 @@
#include "lib/json.h"
#include "lib/keychain.h"
#include "lib/lib_errors.h"
+#include "lib/lib_vty.h"
#include "lib/libfrr.h"
#include "lib/libospf.h"
#include "lib/linklist.h"
#include "lib/log.h"
#include "lib/md5.h"
#include "lib/memory.h"
-#include "lib/memory_vty.h"
#include "lib/mlag.h"
#include "lib/module.h"
#include "lib/monotime.h"
diff --git a/tests/lib/northbound/test_oper_data.c b/tests/lib/northbound/test_oper_data.c
index a28830e088..18d3180889 100644
--- a/tests/lib/northbound/test_oper_data.c
+++ b/tests/lib/northbound/test_oper_data.c
@@ -23,7 +23,7 @@
#include "vty.h"
#include "command.h"
#include "memory.h"
-#include "memory_vty.h"
+#include "lib_vty.h"
#include "log.h"
#include "northbound.h"
@@ -412,7 +412,7 @@ int main(int argc, char **argv)
cmd_init(1);
cmd_hostname_set("test");
vty_init(master, false);
- memory_init();
+ lib_cmd_init();
yang_init();
nb_init(master, modules, array_size(modules));
diff --git a/tests/lib/test_buffer.c b/tests/lib/test_buffer.c
index b56cc30cf3..7fb9a769d3 100644
--- a/tests/lib/test_buffer.c
+++ b/tests/lib/test_buffer.c
@@ -20,7 +20,7 @@
#include <zebra.h>
#include <memory.h>
-#include <memory_vty.h>
+#include <lib_vty.h>
#include <buffer.h>
struct thread_master *master;
@@ -32,7 +32,7 @@ int main(int argc, char **argv)
char junk[3];
char c = 'a';
- memory_init();
+ lib_cmd_init();
if ((argc != 2) || (sscanf(argv[1], "%d%1s", &n, junk) != 1)) {
fprintf(stderr, "Usage: %s <number of chars to simulate>\n",
diff --git a/tests/lib/test_privs.c b/tests/lib/test_privs.c
index de638bc67a..c06ebbeb38 100644
--- a/tests/lib/test_privs.c
+++ b/tests/lib/test_privs.c
@@ -22,7 +22,7 @@
#include "getopt.h"
#include "privs.h"
#include "memory.h"
-#include "memory_vty.h"
+#include "lib_vty.h"
zebra_capabilities_t _caps_p[] = {
ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN, ZCAP_DAC_OVERRIDE,
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
}
/* Library inits. */
- memory_init();
+ lib_cmd_init();
zprivs_preinit(&test_privs);
zprivs_init(&test_privs);
diff --git a/tests/lib/test_versioncmp.c b/tests/lib/test_versioncmp.c
new file mode 100644
index 0000000000..bb819e36f5
--- /dev/null
+++ b/tests/lib/test_versioncmp.c
@@ -0,0 +1,66 @@
+/*
+ * frr_version_cmp() tests
+ * Copyright (C) 2018 David Lamparter for NetDEF, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <zebra.h>
+#include <defaults.h>
+
+static const char *rel(int x)
+{
+ if (x < 0)
+ return "<";
+ if (x > 0)
+ return ">";
+ return "==";
+}
+
+static int fail;
+
+static void compare(const char *a, const char *b, int expect)
+{
+ int result = frr_version_cmp(a, b);
+
+ if (expect == result)
+ printf("\"%s\" %s \"%s\"\n", a, rel(result), b);
+ else {
+ printf("\"%s\" %s \"%s\", expected %s!\n", a, rel(result), b,
+ rel(expect));
+ fail = 1;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ compare("", "", 0);
+ compare("1", "1", 0);
+ compare("1.0", "1.00", 0);
+ compare("10.0", "1", 1);
+ compare("10.0", "2", 1);
+ compare("2.1", "10.0", -1);
+ compare("1.1.1", "1.1.0", 1);
+ compare("1.0a", "1.0", 1);
+ compare("1.0a", "1.0b", -1);
+ compare("1.0a10", "1.0a2", 1);
+ compare("1.00a2", "1.0a2", 0);
+ compare("1.00a2", "1.0a3", -1);
+ compare("1.0-dev", "1.0", 1);
+ compare("1.0~foo", "1.0", -1);
+ compare("1.0~1", "1.0~0", 1);
+ compare("1.00~1", "1.0~0", 1);
+ printf("final tally: %s\n", fail ? "FAILED" : "ok");
+ return fail;
+}
diff --git a/tests/lib/test_versioncmp.py b/tests/lib/test_versioncmp.py
new file mode 100644
index 0000000000..0990757000
--- /dev/null
+++ b/tests/lib/test_versioncmp.py
@@ -0,0 +1,6 @@
+import frrtest
+
+class TestVersionCmp(frrtest.TestMultiOut):
+ program = './test_versioncmp'
+
+TestVersionCmp.exit_cleanly()
diff --git a/tests/subdir.am b/tests/subdir.am
index 270c0811b4..d87d348949 100644
--- a/tests/subdir.am
+++ b/tests/subdir.am
@@ -69,6 +69,7 @@ check_PROGRAMS = \
tests/lib/test_timer_performance \
tests/lib/test_ttable \
tests/lib/test_typelist \
+ tests/lib/test_versioncmp \
tests/lib/test_zlog \
tests/lib/test_graph \
tests/lib/cli/test_cli \
@@ -293,6 +294,10 @@ tests_lib_test_typelist_CFLAGS = $(TESTS_CFLAGS)
tests_lib_test_typelist_CPPFLAGS = $(TESTS_CPPFLAGS)
tests_lib_test_typelist_LDADD = $(ALL_TESTS_LDADD)
tests_lib_test_typelist_SOURCES = tests/lib/test_typelist.c tests/helpers/c/prng.c
+tests_lib_test_versioncmp_CFLAGS = $(TESTS_CFLAGS)
+tests_lib_test_versioncmp_CPPFLAGS = $(TESTS_CPPFLAGS)
+tests_lib_test_versioncmp_LDADD = $(ALL_TESTS_LDADD)
+tests_lib_test_versioncmp_SOURCES = tests/lib/test_versioncmp.c
tests_lib_test_zlog_CFLAGS = $(TESTS_CFLAGS)
tests_lib_test_zlog_CPPFLAGS = $(TESTS_CPPFLAGS)
tests_lib_test_zlog_LDADD = $(ALL_TESTS_LDADD)
@@ -344,6 +349,7 @@ EXTRA_DIST += \
tests/lib/test_ttable.py \
tests/lib/test_ttable.refout \
tests/lib/test_typelist.py \
+ tests/lib/test_versioncmp.py \
tests/lib/test_zlog.py \
tests/lib/test_graph.py \
tests/lib/test_graph.refout \
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py
index 02fba97316..e62d139a0c 100644
--- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py
@@ -153,8 +153,10 @@ def ltemplatePreRouterStartHook():
if topotest.version_cmp(krel, '4.15') >= 0 and \
topotest.version_cmp(krel, '4.18') <= 0:
l3mdev_accept = 1
- else:
- l3mdev_accept = 0
+
+ if topotest.version_cmp(krel, '5.0') >= 0:
+ l3mdev_accept = 1
+
logger.info('setting net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept))
#check for mpls
if tgen.hasmpls != True:
diff --git a/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py b/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py
index 6b4df78c69..2944b3729c 100644
--- a/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py
+++ b/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py
@@ -31,6 +31,7 @@ import sys
import json
from functools import partial
import pytest
+import platform
# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
@@ -68,6 +69,19 @@ def setup_module(mod):
router_list = tgen.routers()
logger.info('Testing with VRF Lite support')
+ krel = platform.release()
+
+ # May need to adjust handling of vrf traffic depending on kernel version
+ l3mdev_accept = 0
+ if topotest.version_cmp(krel, '4.15') >= 0 and \
+ topotest.version_cmp(krel, '4.18') <= 0:
+ l3mdev_accept = 1
+
+ if topotest.version_cmp(krel, '5.0') >= 0:
+ l3mdev_accept = 1
+
+ logger.info('krel \'{0}\' setting net.ipv4.tcp_l3mdev_accept={1}'.format(
+ krel, l3mdev_accept))
cmds = ['ip link add {0}-cust1 type vrf table 1001',
'ip link add loop1 type dummy',
@@ -78,6 +92,15 @@ def setup_module(mod):
for cmd in cmds:
output = tgen.net[rname].cmd(cmd.format(rname))
+ output = tgen.net[rname].cmd('sysctl -n net.ipv4.tcp_l3mdev_accept')
+ logger.info(
+ 'router {0}: existing tcp_l3mdev_accept was {1}'.format(
+ rname, output))
+
+ if l3mdev_accept:
+ output = tgen.net[rname].cmd(
+ 'sysctl -w net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept))
+
for rname, router in router_list.iteritems():
router.load_config(
TopoRouter.RD_ZEBRA,
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index 9f2fef52ea..fc7581b1f2 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -28,6 +28,7 @@ from subprocess import PIPE as SUB_PIPE
from subprocess import Popen
from functools import wraps
from re import search as re_search
+from tempfile import mkdtemp
import StringIO
import os
@@ -276,11 +277,19 @@ def reset_config_on_routers(tgen, routerName=None):
run_cfg_file = "{}/{}/frr.sav".format(TMPDIR, rname)
init_cfg_file = "{}/{}/frr_json_initial.conf".format(TMPDIR, rname)
- command = "/usr/lib/frr/frr-reload.py --input {} --test {} > {}". \
- format(run_cfg_file, init_cfg_file, dname)
+
+ tempdir = mkdtemp()
+ with open(os.path.join(tempdir, 'vtysh.conf'), 'w') as fd:
+ pass
+
+ command = "/usr/lib/frr/frr-reload.py --confdir {} --input {} --test {} > {}". \
+ format(tempdir, run_cfg_file, init_cfg_file, dname)
result = call(command, shell=True, stderr=SUB_STDOUT,
stdout=SUB_PIPE)
+ os.unlink(os.path.join(tempdir, 'vtysh.conf'))
+ os.rmdir(tempdir)
+
# Assert if command fail
if result > 0:
logger.error("Delta file creation failed. Command executed %s",