git: 6d1471fda81a - main - pf tests: support packet size range in pft_ether.py

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 11 Jul 2022 19:58:09 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d1471fda81adcab5c7098f262c9e07b2d6a9fbb

commit 6d1471fda81adcab5c7098f262c9e07b2d6a9fbb
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-07-11 10:17:56 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-07-11 17:55:26 +0000

    pf tests: support packet size range in pft_ether.py
    
    Teach pft_ether.py to send a range of packet sizes. Use this to move the
    size sweep into Python, removing the repeated Python startup overhead
    and greatly speeding up the pf.ether.short_pkt test.
    
    This should fix test timeouts seen on ci.freebsd.org.
    
    While here also extend the range of packet sizes tested, because it adds
    very little runtime now.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/netpfil/pf/ether.sh     | 11 ++++-------
 tests/sys/netpfil/pf/pft_ether.py |  7 ++++++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh
index 7fd55a5d78b5..0fe5069cf74c 100644
--- a/tests/sys/netpfil/pf/ether.sh
+++ b/tests/sys/netpfil/pf/ether.sh
@@ -668,13 +668,10 @@ short_pkt_body()
 	# Try sending ever shorter ping requests
 	# BPF won't let us send anything shorter than an Ethernet header, but
 	# that's good enough for this test
-	for i in `seq 46 14`
-	do
-		$(atf_get_srcdir)/pft_ether.py \
-		    --sendif ${epair}a \
-		    --to 192.0.2.2 \
-		    --len ${i}
-	done
+	$(atf_get_srcdir)/pft_ether.py \
+	    --sendif ${epair}a \
+	    --to 192.0.2.2 \
+	    --len 14-64
 }
 
 short_pkt_cleanup()
diff --git a/tests/sys/netpfil/pf/pft_ether.py b/tests/sys/netpfil/pf/pft_ether.py
index 1892e0a8f95e..4efb974f7897 100644
--- a/tests/sys/netpfil/pf/pft_ether.py
+++ b/tests/sys/netpfil/pf/pft_ether.py
@@ -61,7 +61,12 @@ def main():
 
 	args = parser.parse_args()
 
-	ping(args.sendif[0], args.to[0], int(args.len[0]))
+	if '-' in args.len[0]:
+		s=args.len[0].split('-')
+		for i in range(int(s[0]), int(s[1]) + 1):
+			ping(args.sendif[0], args.to[0], i)
+	else:
+		ping(args.sendif[0], args.to[0], int(args.len[0]))
 
 if __name__ == '__main__':
 	main()