From ca49a76b022c1e493b0d1fc15b8479dcb45ed73c Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Fri, 3 Feb 2017 16:58:11 +0100 Subject: [PATCH] tests: reorganize tests hierarchically Signed-off-by: Christian Franke --- tests/.gitignore | 46 ++--- tests/Makefile.am | 170 ++++++++++-------- tests/{aspath_test.c => bgpd/test_aspath.c} | 0 .../test_capability.c} | 0 .../test_ecommunity.c} | 0 .../test_mp_attr.c} | 0 tests/{bgp_mpath_test.c => bgpd/test_mpath.c} | 0 tests/{ => helpers/c}/main.c | 0 tests/{ => helpers/c}/prng.c | 0 tests/{ => helpers/c}/prng.h | 0 tests/{ => helpers/c}/tests.h | 0 tests/{common-cli.c => lib/cli/common_cli.c} | 2 +- tests/{common-cli.h => lib/cli/common_cli.h} | 0 tests/{test-cli.c => lib/cli/test_cli.c} | 2 +- tests/{testcli.in => lib/cli/test_cli.in} | 0 .../cli/test_cli.refout} | 0 .../cli/test_commands.c} | 0 .../cli/test_commands.in} | 0 .../cli/test_commands.refout} | 0 tests/{test-buffer.c => lib/test_buffer.c} | 0 .../{test-checksum.c => lib/test_checksum.c} | 0 tests/{heavy.c => lib/test_heavy.c} | 0 .../test_heavy_thread.c} | 0 tests/{heavy-wq.c => lib/test_heavy_wq.c} | 0 tests/{test-memory.c => lib/test_memory.c} | 0 .../test_nexthop_iter.c} | 0 tests/{test-privs.c => lib/test_privs.c} | 0 tests/{test-segv.c => lib/test_segv.c} | 0 tests/{test-sig.c => lib/test_sig.c} | 0 .../test_srcdest_table.c} | 0 tests/{test-stream.c => lib/test_stream.c} | 0 tests/lib/test_stream.refout | 8 + tests/{table_test.c => lib/test_table.c} | 0 .../test_timer_correctness.c} | 0 .../test_timer_performance.c} | 0 35 files changed, 128 insertions(+), 100 deletions(-) rename tests/{aspath_test.c => bgpd/test_aspath.c} (100%) rename tests/{bgp_capability_test.c => bgpd/test_capability.c} (100%) rename tests/{ecommunity_test.c => bgpd/test_ecommunity.c} (100%) rename tests/{bgp_mp_attr_test.c => bgpd/test_mp_attr.c} (100%) rename tests/{bgp_mpath_test.c => bgpd/test_mpath.c} (100%) rename tests/{ => helpers/c}/main.c (100%) rename tests/{ => helpers/c}/prng.c (100%) rename tests/{ => helpers/c}/prng.h (100%) rename tests/{ => helpers/c}/tests.h (100%) rename tests/{common-cli.c => lib/cli/common_cli.c} (98%) rename tests/{common-cli.h => lib/cli/common_cli.h} (100%) rename tests/{test-cli.c => lib/cli/test_cli.c} (98%) rename tests/{testcli.in => lib/cli/test_cli.in} (100%) rename tests/{testcli.refout => lib/cli/test_cli.refout} (100%) rename tests/{test-commands.c => lib/cli/test_commands.c} (100%) rename tests/{testcommands.in => lib/cli/test_commands.in} (100%) rename tests/{testcommands.refout => lib/cli/test_commands.refout} (100%) rename tests/{test-buffer.c => lib/test_buffer.c} (100%) rename tests/{test-checksum.c => lib/test_checksum.c} (100%) rename tests/{heavy.c => lib/test_heavy.c} (100%) rename tests/{heavy-thread.c => lib/test_heavy_thread.c} (100%) rename tests/{heavy-wq.c => lib/test_heavy_wq.c} (100%) rename tests/{test-memory.c => lib/test_memory.c} (100%) rename tests/{test-nexthop-iter.c => lib/test_nexthop_iter.c} (100%) rename tests/{test-privs.c => lib/test_privs.c} (100%) rename tests/{test-segv.c => lib/test_segv.c} (100%) rename tests/{test-sig.c => lib/test_sig.c} (100%) rename tests/{test-srcdest-table.c => lib/test_srcdest_table.c} (100%) rename tests/{test-stream.c => lib/test_stream.c} (100%) create mode 100644 tests/lib/test_stream.refout rename tests/{table_test.c => lib/test_table.c} (100%) rename tests/{test-timer-correctness.c => lib/test_timer_correctness.c} (100%) rename tests/{test-timer-performance.c => lib/test_timer_performance.c} (100%) diff --git a/tests/.gitignore b/tests/.gitignore index 3002b27149..1642fa9493 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -16,26 +16,26 @@ TAGS *.xml .arch-inventory .arch-ids -aspathtest -ecommtest -heavy -heavythread -heavywq -tabletest -test-timer-correctness -test-timer-performance -testbgpcap -testbgpmpath -testbgpmpattr -testbuffer -testchecksum -testcli -testmemory -testprivs -testsegv -testsig -teststream -testnexthopiter -testcommands -test-commands-defun.c -site.exp +/bgpd/test_aspath +/bgpd/test_capability +/bgpd/test_ecommunity +/bgpd/test_mp_attr +/bgpd/test_mpath +/lib/cli/test_cli +/lib/cli/test_commands +/lib/cli/test_commands_defun.c +/lib/test_buffer +/lib/test_checksum +/lib/test_heavy +/lib/test_heavy_thread +/lib/test_heavy_wq +/lib/test_memory +/lib/test_nexthop_iter +/lib/test_privs +/lib/test_srcdest_table +/lib/test_segv +/lib/test_sig +/lib/test_stream +/lib/test_table +/lib/test_timer_correctness +/lib/test_timer_performance diff --git a/tests/Makefile.am b/tests/Makefile.am index bee9feaf1e..86e432648c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,99 +1,119 @@ -AUTOMAKE_OPTIONS = dejagnu -DEJATOOL = libfrr - -SUBDIRS = \ - bgpd.tests \ - libfrr.tests - -EXTRA_DIST = \ - config/unix.exp \ - lib/bgpd.exp \ - lib/libfrr.exp \ - global-conf.exp \ - testcommands.in \ - testcommands.refout \ - testcli.in \ - testcli.refout - -AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib +AUTOMAKE_OPTIONS = subdir-objects +AM_CPPFLAGS = \ + -I.. \ + -I$(top_srcdir) \ + -I$(top_srcdir)/lib \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/tests/helpers/c \ + -I$(top_builddir)/tests/helpers/c \ + -O DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\" if BGPD -TESTS_BGPD = aspathtest testbgpcap ecommtest testbgpmpattr testbgpmpath -DEJATOOL += bgpd +TESTS_BGPD = \ + bgpd/test_aspath \ + bgpd/test_capability \ + bgpd/test_ecommunity \ + bgpd/test_mp_attr \ + bgpd/test_mpath else TESTS_BGPD = endif if ENABLE_BGP_VNC -BGP_VNC_RFP_LIB=@top_builddir@/$(LIBRFP)/librfp.a +BGP_VNC_RFP_LIB=@top_builddir@/$(LIBRFP)/librfp.a else BGP_VNC_RFP_LIB = endif -check_PROGRAMS = testsig testsegv testbuffer testmemory heavy heavywq heavythread \ - testprivs teststream testchecksum tabletest testnexthopiter \ - testcommands test-timer-correctness test-timer-performance \ - testcli \ - test-srcdest-table \ - $(TESTS_BGPD) +check_PROGRAMS = \ + lib/test_buffer \ + lib/test_checksum \ + lib/test_heavy_thread \ + lib/test_heavy_wq \ + lib/test_heavy \ + lib/test_memory \ + lib/test_nexthop_iter \ + lib/test_privs \ + lib/test_srcdest_table \ + lib/test_segv \ + lib/test_sig \ + lib/test_stream \ + lib/test_table \ + lib/test_timer_correctness \ + lib/test_timer_performance \ + lib/cli/test_cli \ + lib/cli/test_commands \ + $(TESTS_BGPD) ../vtysh/vtysh_cmd.c: $(MAKE) -C ../vtysh vtysh_cmd.c -test-commands-defun.c: ../vtysh/vtysh_cmd.c +lib/cli/test_commands_defun.c: ../vtysh/vtysh_cmd.c sed \ -e 's/"vtysh\.h"/"tests.h"/' \ -e 's/vtysh_init_cmd/test_init_cmd/' \ -e 's/VTYSH_[A-Z][A-Z_0-9]*/0/g' \ < ../vtysh/vtysh_cmd.c \ - > test-commands-defun.c + > "$@" + +BUILT_SOURCES = lib/cli/test_commands_defun.c + +noinst_HEADERS = \ + ./helpers/c/prng.h \ + ./helpers/c/tests.h \ + ./lib/cli/common_cli.h -BUILT_SOURCES = test-commands-defun.c -noinst_HEADERS = prng.h tests.h common-cli.h +lib_test_buffer_SOURCES = lib/test_buffer.c +lib_test_checksum_SOURCES = lib/test_checksum.c +lib_test_heavy_thread_SOURCES = lib/test_heavy_thread.c helpers/c/main.c +lib_test_heavy_wq_SOURCES = lib/test_heavy_wq.c helpers/c/main.c +lib_test_heavy_SOURCES = lib/test_heavy.c helpers/c/main.c +lib_test_memory_SOURCES = lib/test_memory.c +lib_test_nexthop_iter_SOURCES = lib/test_nexthop_iter.c helpers/c/prng.c +lib_test_privs_SOURCES = lib/test_privs.c +lib_test_srcdest_table_SOURCES = lib/test_srcdest_table.c \ + helpers/c/prng.c +lib_test_segv_SOURCES = lib/test_segv.c +lib_test_sig_SOURCES = lib/test_sig.c +lib_test_stream_SOURCES = lib/test_stream.c +lib_test_table_SOURCES = lib/test_table.c +lib_test_timer_correctness_SOURCES = lib/test_timer_correctness.c \ + helpers/c/prng.c +lib_test_timer_performance_SOURCES = lib/test_timer_performance.c \ + helpers/c/prng.c +lib_cli_test_cli_SOURCES = lib/cli/test_cli.c lib/cli/common_cli.c +lib_cli_test_commands_SOURCES = lib/cli/test_commands_defun.c \ + lib/cli/test_commands.c \ + helpers/c/prng.c +bgpd_test_aspath_SOURCES = bgpd/test_aspath.c +bgpd_test_capability_SOURCES = bgpd/test_capability.c +bgpd_test_ecommunity_SOURCES = bgpd/test_ecommunity.c +bgpd_test_mp_attr_SOURCES = bgpd/test_mp_attr.c +bgpd_test_mpath_SOURCES = bgpd/test_mpath.c -testcli_SOURCES = test-cli.c common-cli.c -testsig_SOURCES = test-sig.c -testsegv_SOURCES = test-segv.c -testbuffer_SOURCES = test-buffer.c -testmemory_SOURCES = test-memory.c -testprivs_SOURCES = test-privs.c -teststream_SOURCES = test-stream.c -heavy_SOURCES = heavy.c main.c -heavywq_SOURCES = heavy-wq.c main.c -heavythread_SOURCES = heavy-thread.c main.c -aspathtest_SOURCES = aspath_test.c -testbgpcap_SOURCES = bgp_capability_test.c -ecommtest_SOURCES = ecommunity_test.c -testbgpmpattr_SOURCES = bgp_mp_attr_test.c -testchecksum_SOURCES = test-checksum.c -testbgpmpath_SOURCES = bgp_mpath_test.c -tabletest_SOURCES = table_test.c -testnexthopiter_SOURCES = test-nexthop-iter.c prng.c -testcommands_SOURCES = test-commands-defun.c test-commands.c prng.c -test_timer_correctness_SOURCES = test-timer-correctness.c prng.c -test_timer_performance_SOURCES = test-timer-performance.c prng.c -test_srcdest_table_SOURCES = test-srcdest-table.c prng.c +ALL_TESTS_LDADD = ../lib/libfrr.la @LIBCAP@ +BGP_TEST_LDADD = ../bgpd/libbgp.a $(BGP_VNC_RFP_LIB) $(ALL_TESTS_LDADD) -lm -testcli_LDADD = ../lib/libfrr.la @LIBCAP@ -testsig_LDADD = ../lib/libfrr.la @LIBCAP@ -testsegv_LDADD = ../lib/libfrr.la @LIBCAP@ -testbuffer_LDADD = ../lib/libfrr.la @LIBCAP@ -testmemory_LDADD = ../lib/libfrr.la @LIBCAP@ -testprivs_LDADD = ../lib/libfrr.la @LIBCAP@ -teststream_LDADD = ../lib/libfrr.la @LIBCAP@ -heavy_LDADD = ../lib/libfrr.la @LIBCAP@ -lm -heavywq_LDADD = ../lib/libfrr.la @LIBCAP@ -lm -heavythread_LDADD = ../lib/libfrr.la @LIBCAP@ -lm -aspathtest_LDADD = ../bgpd/libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ -lm -testbgpcap_LDADD = ../bgpd/libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ -lm -ecommtest_LDADD = ../bgpd/libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ -lm -testbgpmpattr_LDADD = ../bgpd/libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ -lm -testchecksum_LDADD = ../lib/libfrr.la @LIBCAP@ -testbgpmpath_LDADD = ../bgpd/libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ -lm -tabletest_LDADD = ../lib/libfrr.la @LIBCAP@ -lm -testnexthopiter_LDADD = ../lib/libfrr.la @LIBCAP@ -testcommands_LDADD = ../lib/libfrr.la @LIBCAP@ -test_timer_correctness_LDADD = ../lib/libfrr.la @LIBCAP@ -test_timer_performance_LDADD = ../lib/libfrr.la @LIBCAP@ -test_srcdest_table_LDADD = ../lib/libfrr.la @LIBCAP@ +lib_test_buffer_LDADD = $(ALL_TESTS_LDADD) +lib_test_checksum_LDADD = $(ALL_TESTS_LDADD) +lib_test_heavy_thread_LDADD = $(ALL_TESTS_LDADD) -lm +lib_test_heavy_wq_LDADD = $(ALL_TESTS_LDADD) -lm +lib_test_heavy_LDADD = $(ALL_TESTS_LDADD) -lm +lib_test_memory_LDADD = $(ALL_TESTS_LDADD) +lib_test_nexthop_iter_LDADD = $(ALL_TESTS_LDADD) +lib_test_privs_LDADD = $(ALL_TESTS_LDADD) +lib_test_srcdest_table_LDADD = $(ALL_TESTS_LDADD) +lib_test_segv_LDADD = $(ALL_TESTS_LDADD) +lib_test_sig_LDADD = $(ALL_TESTS_LDADD) +lib_test_stream_LDADD = $(ALL_TESTS_LDADD) +lib_test_table_LDADD = $(ALL_TESTS_LDADD) -lm +lib_test_timer_correctness_LDADD = $(ALL_TESTS_LDADD) +lib_test_timer_performance_LDADD = $(ALL_TESTS_LDADD) +lib_cli_test_cli_LDADD = $(ALL_TESTS_LDADD) +lib_cli_test_commands_LDADD = $(ALL_TESTS_LDADD) +bgpd_test_aspath_LDADD = $(BGP_TEST_LDADD) +bgpd_test_capability_LDADD = $(BGP_TEST_LDADD) +bgpd_test_ecommunity_LDADD = $(BGP_TEST_LDADD) +bgpd_test_mp_attr_LDADD = $(BGP_TEST_LDADD) +bgpd_test_mpath_LDADD = $(BGP_TEST_LDADD) diff --git a/tests/aspath_test.c b/tests/bgpd/test_aspath.c similarity index 100% rename from tests/aspath_test.c rename to tests/bgpd/test_aspath.c diff --git a/tests/bgp_capability_test.c b/tests/bgpd/test_capability.c similarity index 100% rename from tests/bgp_capability_test.c rename to tests/bgpd/test_capability.c diff --git a/tests/ecommunity_test.c b/tests/bgpd/test_ecommunity.c similarity index 100% rename from tests/ecommunity_test.c rename to tests/bgpd/test_ecommunity.c diff --git a/tests/bgp_mp_attr_test.c b/tests/bgpd/test_mp_attr.c similarity index 100% rename from tests/bgp_mp_attr_test.c rename to tests/bgpd/test_mp_attr.c diff --git a/tests/bgp_mpath_test.c b/tests/bgpd/test_mpath.c similarity index 100% rename from tests/bgp_mpath_test.c rename to tests/bgpd/test_mpath.c diff --git a/tests/main.c b/tests/helpers/c/main.c similarity index 100% rename from tests/main.c rename to tests/helpers/c/main.c diff --git a/tests/prng.c b/tests/helpers/c/prng.c similarity index 100% rename from tests/prng.c rename to tests/helpers/c/prng.c diff --git a/tests/prng.h b/tests/helpers/c/prng.h similarity index 100% rename from tests/prng.h rename to tests/helpers/c/prng.h diff --git a/tests/tests.h b/tests/helpers/c/tests.h similarity index 100% rename from tests/tests.h rename to tests/helpers/c/tests.h diff --git a/tests/common-cli.c b/tests/lib/cli/common_cli.c similarity index 98% rename from tests/common-cli.c rename to tests/lib/cli/common_cli.c index 47476711c6..83196e04aa 100644 --- a/tests/common-cli.c +++ b/tests/lib/cli/common_cli.c @@ -29,7 +29,7 @@ #include "memory_vty.h" #include "log.h" -#include "common-cli.h" +#include "common_cli.h" struct thread_master *master; diff --git a/tests/common-cli.h b/tests/lib/cli/common_cli.h similarity index 100% rename from tests/common-cli.h rename to tests/lib/cli/common_cli.h diff --git a/tests/test-cli.c b/tests/lib/cli/test_cli.c similarity index 98% rename from tests/test-cli.c rename to tests/lib/cli/test_cli.c index 0590eec713..1a316022e2 100644 --- a/tests/test-cli.c +++ b/tests/lib/cli/test_cli.c @@ -22,7 +22,7 @@ #include -#include "common-cli.h" +#include "common_cli.h" DUMMY_DEFUN(cmd0, "arg ipv4 A.B.C.D"); DUMMY_DEFUN(cmd1, "arg ipv4m A.B.C.D/M"); diff --git a/tests/testcli.in b/tests/lib/cli/test_cli.in similarity index 100% rename from tests/testcli.in rename to tests/lib/cli/test_cli.in diff --git a/tests/testcli.refout b/tests/lib/cli/test_cli.refout similarity index 100% rename from tests/testcli.refout rename to tests/lib/cli/test_cli.refout diff --git a/tests/test-commands.c b/tests/lib/cli/test_commands.c similarity index 100% rename from tests/test-commands.c rename to tests/lib/cli/test_commands.c diff --git a/tests/testcommands.in b/tests/lib/cli/test_commands.in similarity index 100% rename from tests/testcommands.in rename to tests/lib/cli/test_commands.in diff --git a/tests/testcommands.refout b/tests/lib/cli/test_commands.refout similarity index 100% rename from tests/testcommands.refout rename to tests/lib/cli/test_commands.refout diff --git a/tests/test-buffer.c b/tests/lib/test_buffer.c similarity index 100% rename from tests/test-buffer.c rename to tests/lib/test_buffer.c diff --git a/tests/test-checksum.c b/tests/lib/test_checksum.c similarity index 100% rename from tests/test-checksum.c rename to tests/lib/test_checksum.c diff --git a/tests/heavy.c b/tests/lib/test_heavy.c similarity index 100% rename from tests/heavy.c rename to tests/lib/test_heavy.c diff --git a/tests/heavy-thread.c b/tests/lib/test_heavy_thread.c similarity index 100% rename from tests/heavy-thread.c rename to tests/lib/test_heavy_thread.c diff --git a/tests/heavy-wq.c b/tests/lib/test_heavy_wq.c similarity index 100% rename from tests/heavy-wq.c rename to tests/lib/test_heavy_wq.c diff --git a/tests/test-memory.c b/tests/lib/test_memory.c similarity index 100% rename from tests/test-memory.c rename to tests/lib/test_memory.c diff --git a/tests/test-nexthop-iter.c b/tests/lib/test_nexthop_iter.c similarity index 100% rename from tests/test-nexthop-iter.c rename to tests/lib/test_nexthop_iter.c diff --git a/tests/test-privs.c b/tests/lib/test_privs.c similarity index 100% rename from tests/test-privs.c rename to tests/lib/test_privs.c diff --git a/tests/test-segv.c b/tests/lib/test_segv.c similarity index 100% rename from tests/test-segv.c rename to tests/lib/test_segv.c diff --git a/tests/test-sig.c b/tests/lib/test_sig.c similarity index 100% rename from tests/test-sig.c rename to tests/lib/test_sig.c diff --git a/tests/test-srcdest-table.c b/tests/lib/test_srcdest_table.c similarity index 100% rename from tests/test-srcdest-table.c rename to tests/lib/test_srcdest_table.c diff --git a/tests/test-stream.c b/tests/lib/test_stream.c similarity index 100% rename from tests/test-stream.c rename to tests/lib/test_stream.c diff --git a/tests/lib/test_stream.refout b/tests/lib/test_stream.refout new file mode 100644 index 0000000000..cf52e1301e --- /dev/null +++ b/tests/lib/test_stream.refout @@ -0,0 +1,8 @@ +endp: 15, readable: 15, writeable: 1009 +0xef 0xbe 0xef 0xde 0xad 0xbe 0xef 0xde 0xad 0xbe 0xef 0xde 0xad 0xbe 0xef +endp: 15, readable: 15, writeable: 0 +0xef 0xbe 0xef 0xde 0xad 0xbe 0xef 0xde 0xad 0xbe 0xef 0xde 0xad 0xbe 0xef +c: 0xef +w: 0xbeef +l: 0xdeadbeef +q: 0xdeadbeefdeadbeef diff --git a/tests/table_test.c b/tests/lib/test_table.c similarity index 100% rename from tests/table_test.c rename to tests/lib/test_table.c diff --git a/tests/test-timer-correctness.c b/tests/lib/test_timer_correctness.c similarity index 100% rename from tests/test-timer-correctness.c rename to tests/lib/test_timer_correctness.c diff --git a/tests/test-timer-performance.c b/tests/lib/test_timer_performance.c similarity index 100% rename from tests/test-timer-performance.c rename to tests/lib/test_timer_performance.c -- 2.39.5