Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jun 2021 15:43:06 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 09cb8c812b2f - stable/12 - pf tests: Make killstate:match more robust
Message-ID:  <202106071543.157Fh6m8037205@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=09cb8c812b2fdf1d1e95cf6237a14c616169c1bb

commit 09cb8c812b2fdf1d1e95cf6237a14c616169c1bb
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-06-03 13:22:19 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-06-07 08:35:45 +0000

    pf tests: Make killstate:match more robust
    
    The killstate:match test starts nc as a background process. There was no
    guarantee that the nc process would have connected by the time we check
    for states, so this test occasionally failed without good reason.
    
    Teach the test to wait for at least some states to turn up before
    executing the critical checks.
    
    MFC after:      3 days
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit 70dd30d49c29a27e1ef159660a7e3dbb84082674)
---
 tests/sys/netpfil/pf/killstate.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh
index b811befc08c5..2b77ea189294 100644
--- a/tests/sys/netpfil/pf/killstate.sh
+++ b/tests/sys/netpfil/pf/killstate.sh
@@ -312,6 +312,17 @@ match_head()
 	atf_set require.user root
 }
 
+wait_for_state()
+{
+	jail=$1
+	addr=$2
+
+	while ! jexec $jail pfctl -s s | grep $addr >/dev/null;
+	do
+		sleep .1
+	done
+}
+
 match_body()
 {
 	pft_init
@@ -340,6 +351,7 @@ match_body()
 		"pass all"
 
 	nc 198.51.100.2 7 &
+	wait_for_state alcatraz 192.0.2.1
 
 	# Expect two states
 	states=$(jexec alcatraz pfctl -s s | wc -l)
@@ -360,6 +372,7 @@ match_body()
 	jexec alcatraz pfctl -F states
 
 	nc 198.51.100.2 7 &
+	wait_for_state alcatraz 192.0.2.1
 
 	# Kill matching states, expect all of them to be gone
 	jexec alcatraz pfctl -M -k 192.0.2.1



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106071543.157Fh6m8037205>