From 7a822206db165bc456c07684c7f2620958847bef Mon Sep 17 00:00:00 2001 From: seuzw <930zhaowei@163.com> Date: Tue, 13 Sep 2022 14:55:34 +0800 Subject: [PATCH] enable test --- enable-make-check-tests.patch | 90 +++++++++++++++++++++++++++++++++++ libnetfilter_conntrack.spec | 15 +++++- 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 enable-make-check-tests.patch diff --git a/enable-make-check-tests.patch b/enable-make-check-tests.patch new file mode 100644 index 0000000..cb648c3 --- /dev/null +++ b/enable-make-check-tests.patch @@ -0,0 +1,90 @@ +From e02ad202d6eec5ee012e24cb1901167f07511055 Mon Sep 17 00:00:00 2001 +From: zhangwenhao +Date: Thu, 28 Jan 2021 22:41:36 +0800 +Subject: [PATCH] enable make check tests + +--- + tests/Makefile.in | 7 +++++++ + tests/ct_events_reliable.c | 4 +++- + tests/qa-connlabel.conf | 11 +++++++++++ + tests/test_filter.c | 5 ++++- + 4 files changed, 25 insertions(+), 2 deletions(-) + create mode 100644 tests/qa-connlabel.conf + +diff --git a/tests/Makefile.in b/tests/Makefile.in +index 7fb8924..4c600df 100644 +--- a/tests/Makefile.in ++++ b/tests/Makefile.in +@@ -520,6 +520,13 @@ distdir: $(DISTFILES) + done + check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) ++ ./test_api ++ ./test_connlabel ++ ./ct_stress 10000 & ./test_filter ++ ../utils/conntrack_flush ++ ./ct_stress 10000 & ./ct_events_reliable ++ ../utils/conntrack_flush ++ + check: check-am + all-am: Makefile + installdirs: +diff --git a/tests/ct_events_reliable.c b/tests/ct_events_reliable.c +index b51d0e5..26ff8e9 100644 +--- a/tests/ct_events_reliable.c ++++ b/tests/ct_events_reliable.c +@@ -20,9 +20,11 @@ static int event_cb(enum nf_conntrack_msg_type type, + else if (type == NFCT_T_DESTROY) + destroy++; + +- if ((++events % 10000) == 0) ++ if ((++events % 3) == 0) { + printf("%d events received (%d new, %d update, %d destroy)\n", + events, new, update, destroy); ++ return NFCT_CB_STOP; ++ } + + return NFCT_CB_CONTINUE; + } +diff --git a/tests/qa-connlabel.conf b/tests/qa-connlabel.conf +new file mode 100644 +index 0000000..38c3115 +--- /dev/null ++++ b/tests/qa-connlabel.conf +@@ -0,0 +1,11 @@ ++0 zero ++# duplicate names should be skipped ++1 zero ++1 test label 1 ++1 zero ++# .. so this should have added bit 1 as "test label 1" ++2 test label 2 ++# duplicate bit, should be skipped, too ++2 duplicate ++5 unused label ++42 T +diff --git a/tests/test_filter.c b/tests/test_filter.c +index 7877819..efc7c3b 100644 +--- a/tests/test_filter.c ++++ b/tests/test_filter.c +@@ -20,7 +20,7 @@ static int event_cb(enum nf_conntrack_msg_type type, + nfct_snprintf(buf, sizeof(buf), ct, type, NFCT_O_PLAIN, NFCT_OF_TIME); + printf("%s\n", buf); + +- if (++n == 10) ++ if (++n == 1) + return NFCT_CB_STOP; + + return NFCT_CB_CONTINUE; +@@ -61,6 +61,9 @@ int main(void) + .addr = ntohl(inet_addr("127.0.0.1")) + i, + .mask = 0xffffffff, + }; ++ nfct_filter_set_logic(filter, ++ NFCT_FILTER_SRC_IPV4, ++ NFCT_FILTER_LOGIC_NEGATIVE); + nfct_filter_add_attr(filter, NFCT_FILTER_SRC_IPV4, &fltr_ipv4); + }; + +-- +2.23.0 \ No newline at end of file diff --git a/libnetfilter_conntrack.spec b/libnetfilter_conntrack.spec index c57d41b..a8b570e 100644 --- a/libnetfilter_conntrack.spec +++ b/libnetfilter_conntrack.spec @@ -1,11 +1,15 @@ +#needsrootforbuild + Name: libnetfilter_conntrack Version: 1.0.8 -Release: 2 +Release: 3 Summary: A userspace library providing a API License: GPLv2+ URL: http://netfilter.org Source0: http://netfilter.org/projects/libnetfilter_conntrack/files/%{name}-%{version}.tar.bz2 +Patch0: enable-make-check-tests.patch + BuildRequires: pkgconfig kernel-headers BuildRequires: libmnl-devel >= 1.0.3 libnfnetlink-devel >= 1.0.1 @@ -35,6 +39,9 @@ This package contains development files. %make_install %delete_la +%check +make check + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -48,6 +55,12 @@ This package contains development files. %{_libdir}/*.so %changelog +* Tue Sep 13 2022 seuzw <930zhaowei@163.com> - 1.0.8-3 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:enable test + * Thu May 27 2021 lijingyuan - 1.0.8-2 - Type:bugfix - ID:NA