mirror of
https://github.com/openbsd/src.git
synced 2024-12-21 23:18:00 -08:00
Replace poor man's synchronization primitive (i.e. sleep) with a wait
until construct in the hopes of making these tests less flaky.
This commit is contained in:
parent
7ed182d8b9
commit
d6933ec7e0
@ -1,9 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/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
|
# test if tail follows a file overwritten by data
|
||||||
|
|
||||||
|
. "$(dirname "${0}")/util.sh"
|
||||||
|
|
||||||
#set TMPDIR to a nfs-based dir for nfs testing
|
#set TMPDIR to a nfs-based dir for nfs testing
|
||||||
DIR=$(mktemp -d)
|
DIR=$(mktemp -d)
|
||||||
echo DIR=${DIR}
|
echo DIR=${DIR}
|
||||||
@ -30,8 +32,7 @@ echo 'baar' > ${DIR}/bar
|
|||||||
# smaller data without delay
|
# smaller data without delay
|
||||||
echo 'bar' > ${DIR}/bar
|
echo 'bar' > ${DIR}/bar
|
||||||
|
|
||||||
# hey nfs !
|
wait_until "[ `grep -c bar ${OUT}` = 2 ]"
|
||||||
sleep 5
|
|
||||||
kill ${PID}
|
kill ${PID}
|
||||||
diff -u ${OUT} ${0%%.sh}.out || exit 1
|
diff -u ${OUT} ${0%%.sh}.out || exit 1
|
||||||
[ $(grep -c "tail: ${DIR}/bar has been truncated, resetting." ${ERR}) -eq 3 ] || exit 2
|
[ $(grep -c "tail: ${DIR}/bar has been truncated, resetting." ${ERR}) -eq 3 ] || exit 2
|
||||||
|
13
regress/usr.bin/tail/util.sh
Normal file
13
regress/usr.bin/tail/util.sh
Normal file
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user