summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-03-16 12:09:15 +0100
committerThomas Haller <thaller@redhat.com>2022-03-16 23:56:20 +0100
commit1fc3e07924fa38856ea76d5be1bd51d96932c072 (patch)
treeeccc17c4304cd1840de6883f62e479695246251d
parent7a3d6e23a0cfb80201ffe4a1377b9526bfe5470a (diff)
downloadlibnl-1fc3e07924fa38856ea76d5be1bd51d96932c072.tar.gz
tests: refactor tests and add n-test-util helper library
- we have "check-all.c" and "check-direct.c", which contains the main functions of the actual tests. On the other hand, the other "check-{addr,attr,ematch-tree-clone}.c" files only contained the test suites for "check-all.c". Rename the latter to have a separate name prefix. - rename "tests/util.h" to "tests/cksuite-all.h". It's really the header that declares all the suites. - add a "tests/nl-test-util.c" as a static helper library with test code.
-rw-r--r--Makefile.am44
-rw-r--r--tests/check-all.c4
-rw-r--r--tests/cksuite-all-addr.c (renamed from tests/check-addr.c)2
-rw-r--r--tests/cksuite-all-attr.c (renamed from tests/check-attr.c)2
-rw-r--r--tests/cksuite-all-ematch-tree-clone.c (renamed from tests/check-ematch-tree-clone.c)2
-rw-r--r--tests/cksuite-all.h11
-rw-r--r--tests/nl-test-util.c3
-rw-r--r--tests/nl-test-util.h8
-rw-r--r--tests/util.h6
9 files changed, 59 insertions, 23 deletions
diff --git a/Makefile.am b/Makefile.am
index ab4a825d..4be43952 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -845,7 +845,25 @@ tests_ldadd = \
lib/libnl-3.la \
lib/libnl-nf-3.la \
lib/libnl-genl-3.la \
- lib/libnl-route-3.la
+ lib/libnl-route-3.la \
+ $(NULL)
+
+if WITH_CHECK
+check_LTLIBRARIES += tests/libnl-test-util.la
+endif
+
+tests_libnl_test_util_la_SOURCES = \
+ tests/nl-test-util.h \
+ tests/nl-test-util.c \
+ $(NULL)
+tests_libnl_test_util_la_CPPFLAGS = \
+ $(tests_cppflags) \
+ $(CHECK_CFLAGS) \
+ $(NULL)
+tests_libnl_test_util_la_LIBADD = \
+ $(tests_ldadd) \
+ $(CHECK_LIBS) \
+ $(NULL)
check_PROGRAMS += \
tests/test-complex-HTB-with-hash-filters \
@@ -926,11 +944,13 @@ tests_test_u32_filter_with_actions_LDADD = $(tests_ldadd)
check_PROGRAMS += \
tests/test-cache-mngr \
tests/test-genl \
- tests/test-nf-cache-mngr
+ tests/test-nf-cache-mngr \
+ $(NULL)
tests_cli_ldadd = \
$(tests_ldadd) \
- src/lib/libnl-cli-3.la
+ src/lib/libnl-cli-3.la \
+ $(NULL)
tests_test_cache_mngr_CPPFLAGS = $(tests_cppflags)
tests_test_cache_mngr_LDADD = $(tests_cli_ldadd)
@@ -945,11 +965,11 @@ check_programs += tests/check-all
endif
tests_check_all_SOURCES = \
- tests/check-addr.c \
tests/check-all.c \
- tests/check-attr.c \
- tests/check-ematch-tree-clone.c \
- tests/util.h \
+ tests/cksuite-all.h \
+ tests/cksuite-all-addr.c \
+ tests/cksuite-all-attr.c \
+ tests/cksuite-all-ematch-tree-clone.c \
$(NULL)
tests_check_all_CPPFLAGS = \
@@ -958,7 +978,9 @@ tests_check_all_CPPFLAGS = \
tests_check_all_LDADD = \
$(tests_ldadd) \
- $(CHECK_LIBS)
+ tests/libnl-test-util.la \
+ $(CHECK_LIBS) \
+ $(NULL)
if WITH_CHECK
check_programs += tests/check-direct
@@ -978,10 +1000,8 @@ tests_check_direct_LDFLAGS = \
$(NULL)
tests_check_direct_LDADD = \
- lib/libnl-3.la \
- lib/libnl-nf-3.la \
- lib/libnl-genl-3.la \
- lib/libnl-route-3.la \
+ $(tests_ldadd) \
+ tests/libnl-test-util.la \
$(CHECK_LIBS) \
$(NULL)
diff --git a/tests/check-all.c b/tests/check-all.c
index f9c75c40..b8f9222a 100644
--- a/tests/check-all.c
+++ b/tests/check-all.c
@@ -5,7 +5,7 @@
#include <check.h>
-#include "util.h"
+#include "cksuite-all.h"
static Suite *main_suite(void)
{
@@ -18,7 +18,7 @@ int main(int argc, char *argv[])
{
SRunner *runner;
int nfailed;
-
+
runner = srunner_create(main_suite());
/* Add testsuites below */
diff --git a/tests/check-addr.c b/tests/cksuite-all-addr.c
index 8c61ea9c..3ae1feee 100644
--- a/tests/check-addr.c
+++ b/tests/cksuite-all-addr.c
@@ -7,7 +7,7 @@
#include <netlink/addr.h>
#include <netlink/route/addr.h>
-#include "util.h"
+#include "cksuite-all.h"
START_TEST(addr_alloc)
{
diff --git a/tests/check-attr.c b/tests/cksuite-all-attr.c
index 0a375538..76e2ecef 100644
--- a/tests/check-attr.c
+++ b/tests/cksuite-all-attr.c
@@ -6,7 +6,7 @@
#include <linux/netlink.h>
#include <linux/if_ether.h>
-#include "util.h"
+#include "cksuite-all.h"
#include "netlink/attr.h"
#include "netlink/msg.h"
#include "netlink/route/cls/u32.h"
diff --git a/tests/check-ematch-tree-clone.c b/tests/cksuite-all-ematch-tree-clone.c
index 9f69646f..76684572 100644
--- a/tests/check-ematch-tree-clone.c
+++ b/tests/cksuite-all-ematch-tree-clone.c
@@ -5,7 +5,7 @@
#include "netlink-private/types.h"
#include "netlink/route/cls/ematch.h"
-#include "util.h"
+#include "cksuite-all.h"
#include "netlink-private/nl-auto.h"
#define MAX_DEPTH 6
diff --git a/tests/cksuite-all.h b/tests/cksuite-all.h
new file mode 100644
index 00000000..a2e27fbb
--- /dev/null
+++ b/tests/cksuite-all.h
@@ -0,0 +1,11 @@
+#ifndef __LIBNL3_TESTS_CHECK_ALL_H__
+#define __LIBNL3_TESTS_CHECK_ALL_H__
+
+#include <check.h>
+#include "nl-test-util.h"
+
+Suite *make_nl_attr_suite(void);
+Suite *make_nl_addr_suite(void);
+Suite *make_nl_ematch_tree_clone_suite(void);
+
+#endif /* __LIBNL3_TESTS_CHECK_ALL_H__ */
diff --git a/tests/nl-test-util.c b/tests/nl-test-util.c
new file mode 100644
index 00000000..b37b44b7
--- /dev/null
+++ b/tests/nl-test-util.c
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: LGPL-2.1-only */
+
+#include "nl-test-util.h"
diff --git a/tests/nl-test-util.h b/tests/nl-test-util.h
new file mode 100644
index 00000000..0b99c76c
--- /dev/null
+++ b/tests/nl-test-util.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: LGPL-2.1-only */
+
+#ifndef __NL_TEST_UTIL_H__
+#define __NL_TEST_UTIL_H__
+
+#include <check.h>
+
+#endif /* __NL_TEST_UTIL_H__ */
diff --git a/tests/util.h b/tests/util.h
deleted file mode 100644
index ba182097..00000000
--- a/tests/util.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <check.h>
-
-Suite *make_nl_attr_suite(void);
-Suite *make_nl_addr_suite(void);
-Suite *make_nl_ematch_tree_clone_suite(void);
-