From 0332ec238116d6cd2c2015f42cf26661a48b5e73 Mon Sep 17 00:00:00 2001 From: anton Date: Mon, 11 Oct 2021 05:45:43 +0000 Subject: [PATCH] Replace poor man's synchronization primitive (i.e. sleep) with a wait-until-condition-is-true loop in the hopes of making these tests less flaky. ok benno@ --- .../integrationtests/network_statement.sh | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/regress/usr.sbin/bgpd/integrationtests/network_statement.sh b/regress/usr.sbin/bgpd/integrationtests/network_statement.sh index 0b28dcafac6..58e209c6e80 100644 --- a/regress/usr.sbin/bgpd/integrationtests/network_statement.sh +++ b/regress/usr.sbin/bgpd/integrationtests/network_statement.sh @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: network_statement.sh,v 1.4 2019/08/06 07:31:53 claudio Exp $ +# $OpenBSD: network_statement.sh,v 1.5 2021/10/11 05:45:43 anton Exp $ set -e @@ -34,6 +34,7 @@ error_notify() { route -qn -T ${RDOMAIN2} flush || true ifconfig lo${RDOMAIN1} destroy || true ifconfig lo${RDOMAIN2} destroy || true + rm -f ${TMP} if [ $1 -ne 0 ]; then echo FAILED exit 1 @@ -42,6 +43,19 @@ error_notify() { fi } +wait_until() { + local _i=0 + + cat >"$TMP" + while [ "$_i" -lt 4 ]; do + sh -x "$TMP" && return 0 + sleep 0.5 + _i="$((_i + 1))" + done + echo timeout + return 1 +} + if [ "$(id -u)" -ne 0 ]; then echo need root privileges >&2 exit 1 @@ -49,6 +63,8 @@ fi trap 'error_notify $?' EXIT +TMP="$(mktemp -t bgpd.XXXXXX)" + echo check if rdomains are busy for n in ${RDOMAINS}; do if /sbin/ifconfig | grep -v "^lo${n}:" | grep " rdomain ${n} "; then @@ -84,7 +100,9 @@ route -T ${RDOMAIN1} exec ${BGPD} \ route -T ${RDOMAIN2} exec ${BGPD} \ -v -f ${BGPDCONFIGDIR}/bgpd.network_statement.rdomain2.conf -sleep 2 +wait_until <