diff --git a/regress/usr.bin/tail/follow-overwrite-data.sh b/regress/usr.bin/tail/follow-overwrite-data.sh index f11ee4b9d0f..e51667de029 100644 --- a/regress/usr.bin/tail/follow-overwrite-data.sh +++ b/regress/usr.bin/tail/follow-overwrite-data.sh @@ -1,9 +1,11 @@ #!/bin/sh # -# $OpenBSD: follow-overwrite-data.sh,v 1.2 2012/11/03 08:41:25 ajacoutot Exp $ +# $OpenBSD: follow-overwrite-data.sh,v 1.3 2024/12/21 07:49:03 anton Exp $ # test if tail follows a file overwritten by data +. "$(dirname "${0}")/util.sh" + #set TMPDIR to a nfs-based dir for nfs testing DIR=$(mktemp -d) echo DIR=${DIR} @@ -30,8 +32,7 @@ echo 'baar' > ${DIR}/bar # smaller data without delay echo 'bar' > ${DIR}/bar -# hey nfs ! -sleep 5 +wait_until "[ `grep -c bar ${OUT}` = 2 ]" kill ${PID} diff -u ${OUT} ${0%%.sh}.out || exit 1 [ $(grep -c "tail: ${DIR}/bar has been truncated, resetting." ${ERR}) -eq 3 ] || exit 2 diff --git a/regress/usr.bin/tail/util.sh b/regress/usr.bin/tail/util.sh new file mode 100644 index 00000000000..de04563193f --- /dev/null +++ b/regress/usr.bin/tail/util.sh @@ -0,0 +1,13 @@ +# $OpenBSD: util.sh,v 1.1 2024/12/21 07:49:03 anton Exp $ + +wait_until() { + local _i=0 + + while [ "$_i" -lt 8 ]; do + sh -x -c "$*" && return 0 + sleep 0.5 + _i="$((_i + 1))" + done + echo timeout + return 1 +}