Skip to contentSkip to conversation

tests: nfct: make it suitable for CI pipeline

PATCH New Florian Westphal 1 participant 1 message Apr 28 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 tests: nfct: make it suitable for CI pipeline

1. make run-test.sh call test prog via unshare -n.
2. remove various modprobe calls, these are all built into nf_conntrack.ko.
3. make test.c exit nonzero when bad tests are detected.
4. remove dccp+udplite, they fail on modern kernels due to removal of these protocols.
5. update test-live.sh. Auto-rexec via unshare. Streamline output:

Check timeout policy test-generic for protocol 13

    [NEW] unknown  13 3 src=10.0.0.1 dst=8.8.8.8 [UNREPLIED] src=8.8.8.8 dst=10.0.0.1
Check timeout policy test-tcp for protocol tcp
    [NEW] tcp      6 2 SYN_SENT src=10.0.0.1 dst=8.8.8.8 sport=5050 dport=80 [UNREPLIED] src=8.8.8.8 dst=10.0.0.1 sport=80 dport=5050
Check timeout policy test-icmp for protocol icmp
    [NEW] icmp     1 4 src=10.0.0.1 dst=8.8.8.8 type=8 code=0 id=41473 [UNREPLIED] src=8.8.8.8 dst=10.0.0.1 type=0 code=0 id=41473

The effective timeout is validated by checking the new timeout reported via ctnetlink.

---
 tests/nfct/run-test.sh       |  15 +----
 tests/nfct/test-live.sh      | 125 +++++++++++++++++++++++------------
 tests/nfct/test.c            |   4 ++
 tests/nfct/timeout/03udplite |  16 -----
 tests/nfct/timeout/07dccp    |  16 -----
 5 files changed, 89 insertions(+), 87 deletions(-)
 mode change 100644 => 100755 tests/nfct/run-test.sh
 mode change 100644 => 100755 tests/nfct/test-live.sh
 delete mode 100644 tests/nfct/timeout/03udplite
 delete mode 100644 tests/nfct/timeout/07dccp
tests/nfct/run-test.sh +2 -13
old mode 100644
new mode 100755
index f5f220baebf1..88999f8c8517
@@ -7,16 +7,5 @@ then
 	exit 1
 fi
 
-gcc test.c -o test
-#
-# XXX: module auto-load not support by nfnetlink_cttimeout yet :-(
-#
-# any or all of these might be built-ins rather than modules, so don't error
-# out on failure from modprobe
-modprobe nf_conntrack_ipv4 || true
-modprobe nf_conntrack_ipv6 || true
-modprobe nf_conntrack_proto_udplite || true
-modprobe nf_conntrack_proto_sctp || true
-modprobe nf_conntrack_proto_dccp || true
-modprobe nf_conntrack_proto_gre || true
-./test timeout
+test -x test || gcc test.c -o test
+exec unshare -n ./test timeout
tests/nfct/test-live.sh +83 -42

154 lines not on this page · raw message

tests/nfct/test.c +4 -0
index a833dcc9e99b..bce927829190 100644
@@ -97,4 +97,8 @@ int main(int argc, char *argv[])
 	closedir(d);
 
 	fprintf(stdout, "OK: %d BAD: %d\n", ok, bad);
+	if (bad)
+		return 1;
+
+	return ok > 0 ? 0 : 1;
 }
tests/nfct/timeout/03udplite deleted +0 -16
deleted file mode 100644
index 8ed345901651..000000000000
@@ -1,16 +0,0 @@
-# add policy object `test'
-nfct add timeout test inet udplite unreplied 10 ; OK
-# get policy object `test'
-nfct get timeout test ; OK
-# delete policy object `test'
-nfct delete timeout test ; OK
-# get unexistent policy object `dummy'
-nfct get timeout test ; BAD
-# delete policy object `test', however, it does not exists anymore
-nfct delete timeout test ; BAD
-# add policy object `test'
-nfct add timeout test inet udplite unreplied 1 replied 2 ; OK
-# get policy object `test'
-nfct get timeout test ; OK
-# delete policy object `test'
-nfct delete timeout test ; OK
tests/nfct/timeout/07dccp deleted +0 -16
deleted file mode 100644
index 1d885853f577..000000000000
@@ -1,16 +0,0 @@
-# add policy object `test'
-nfct add timeout test inet dccp request 100 ; OK
-# get policy object `test'
-nfct get timeout test ; OK
-# delete policy object `test'
-nfct delete timeout test ; OK
-# get unexistent policy object `dummy'
-nfct get timeout test ; BAD
-# delete policy object `test', however, it does not exists anymore
-nfct delete timeout test ; BAD
-# add policy object `test'
-nfct add timeout test inet dccp request 1 respond 2 partopen 3 open 4 closereq 5 closing 6 timewait 7 ; OK
-# get policy object `test'
-nfct get timeout test ; OK
-# delete policy object `test'
-nfct delete timeout test ; OK
Signature · 1 line
2.53.0