git: 2a4cd9f8c82d - main - tests/arp: Add a 1-second tolerance

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Fri, 25 Apr 2025 21:05:52 UTC
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/src/commit/?id=2a4cd9f8c82d73784af99067272ae169affb29c6

commit 2a4cd9f8c82d73784af99067272ae169affb29c6
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2025-04-25 20:57:25 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2025-04-25 21:03:21 +0000

    tests/arp: Add a 1-second tolerance
    
    This test could be flaky in case of a 1-second delay between the ping and the
    ARP cache display, which can happen on highly loaded hosts running multiple
    regression test VMs
    
    Approved by:    glebius
    Obtained from:  glebius
    Sponsored by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D50039
---
 tests/sys/netinet/arp.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/sys/netinet/arp.sh b/tests/sys/netinet/arp.sh
index c7744d5de938..df5dbc50ffa1 100755
--- a/tests/sys/netinet/arp.sh
+++ b/tests/sys/netinet/arp.sh
@@ -188,7 +188,9 @@ static_body() {
 
 	ipa=198.51.100.1
 	ipb=198.51.100.2
+	ipb_re=$(echo ${ipb} | sed 's/\./\\./g')
 	max_age=$(sysctl -n net.link.ether.inet.max_age)
+	max_age="(${max_age}|$((${max_age} - 1)))"
 
 	atf_check ifconfig -j ${jname}a ${epair0}a inet ${ipa}/24
 	eth="$(ifconfig -j ${jname}b ${epair0}b |
@@ -197,8 +199,8 @@ static_body() {
 	# Expected outputs
 	permanent=\
 "? (${ipb}) at 00:00:00:00:00:00 on ${epair0}a permanent [ethernet]\n"
-	temporary=\
-"? (${ipb}) at ${eth} on ${epair0}a expires in ${max_age} seconds [ethernet]\n"
+	temporary_re=\
+"\? \(${ipb_re}\) at ${eth} on ${epair0}a expires in ${max_age} seconds \[ethernet\]"
 	deleted=\
 "${ipb} (${ipb}) deleted\n"
 
@@ -217,7 +219,7 @@ static_body() {
 	# then check -S
 	atf_check -o "inline:${deleted}" jexec ${jname}a arp -nd ${ipb}
 	atf_check -o ignore jexec ${jname}b ping -c1 ${ipa}
-	atf_check -o "inline:${temporary}" jexec ${jname}a arp -n ${ipb}
+	atf_check -o "match:${temporary_re}" jexec ${jname}a arp -n ${ipb}
 	# Note: this doesn't fail, tracked all the way down to FreeBSD 8
 	# atf_check -s not-exit:0 jexec ${jname}a arp -s ${ipb} 0:0:0:0:0:0
 	atf_check -o "inline:${deleted}" \