summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/packetpath
diff options
context:
space:
mode:
authorYi Chen <yiche@redhat.com>2025-06-22 20:55:53 +0800
committerFlorian Westphal <fw@strlen.de>2025-06-22 15:28:28 +0200
commitfe51e4e2dfece307f19ae88155d1ad836bc43317 (patch)
tree1a7aac38b95c4da9a6752a952f582b41ecc1bc34 /tests/shell/testcases/packetpath
parentf21d7d4bf853960f5b1bb4d5ac280b25682fa088 (diff)
test: shell: Add wait_local_port_listen() helper to lib.sh
Introduce a new helper function wait_local_port_listen() in helpers/lib.sh. Update the flowtables and nat_ftp test cases to use this helper. Signed-off-by: Yi Chen <yiche@redhat.com> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/testcases/packetpath')
-rwxr-xr-xtests/shell/testcases/packetpath/flowtables3
-rwxr-xr-xtests/shell/testcases/packetpath/nat_ftp6
2 files changed, 6 insertions, 3 deletions
diff --git a/tests/shell/testcases/packetpath/flowtables b/tests/shell/testcases/packetpath/flowtables
index f3580a5f..dbe470a8 100755
--- a/tests/shell/testcases/packetpath/flowtables
+++ b/tests/shell/testcases/packetpath/flowtables
@@ -83,7 +83,8 @@ assert_pass "set net.netfilter.nf_conntrack_tcp_timeout_established=86400"
# A trick to control the timing to send a packet
ip netns exec $S socat TCP6-LISTEN:10001 GOPEN:/tmp/socat-$rnd,ignoreeof &
-sleep 1
+wait_local_port_listen $S 10001 tcp
+
ip netns exec $C socat -b 2048 PIPE:/tmp/pipefile-$rnd 'TCP:[2001:db8:ffff:22::1]:10001' &
sleep 1
ip netns exec $C echo "send sth" >> /tmp/pipefile-$rnd ; assert_pass "send a packet"
diff --git a/tests/shell/testcases/packetpath/nat_ftp b/tests/shell/testcases/packetpath/nat_ftp
index 2a80c43f..c2fb3a1c 100755
--- a/tests/shell/testcases/packetpath/nat_ftp
+++ b/tests/shell/testcases/packetpath/nat_ftp
@@ -133,7 +133,8 @@ pam_service_name=vsftpd
background=YES
EOF
ip netns exec $S vsftpd ${FTPCONF}
-sleep 1
+wait_local_port_listen $S 21 tcp
+
ip netns exec $S ss -6ltnp | grep -q '*:21'
assert_pass "start vsftpd server"
@@ -142,7 +143,7 @@ assert_pass "start vsftpd server"
reload_ruleset
ip netns exec $S tcpdump -q --immediate-mode -Ui s_r -w ${PCAP} 2> /dev/null &
pid=$!
-sleep 1
+sleep 0.5
ip netns exec $C curl --no-progress-meter --connect-timeout 5 ftp://[${ip_rc}]:2121/$(basename $INFILE) -o $OUTFILE
assert_pass "curl ftp passive mode "
@@ -159,6 +160,7 @@ reload_ruleset
ip netns exec $S tcpdump -q --immediate-mode -Ui s_r -w ${PCAP} 2> /dev/null &
pid=$!
+sleep 0.5
ip netns exec $C curl --no-progress-meter -P - --connect-timeout 5 ftp://[${ip_rc}]:2121/$(basename $INFILE) -o $OUTFILE
assert_pass "curl ftp active mode "