mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
tests: make various timeouts more robust
* tests/init.cfg (retry_delay_): Describe the backoff method used. * tests/ls/readdir-mountpoint-inode: Add a timeout to the stat call to eliminate the chance of hangups. * tests/mv/i-3: Change the timeout required to pass from 1 second to a range of .1s - 3.1s. * tests/rm/dangling-symlink: Likewise.
This commit is contained in:
1 parent
437671accc
commit
c52d220c30
4 files changed
+26
-18
No files matched your search
+2
-1
@@ -369,7 +369,8 @@ working_umask_or_skip_()
|
||||
esac
|
||||
}
|
||||
|
||||
# Continually retry a function requiring a sufficient delay to _pass_
|
||||
# Retry a function requiring a sufficient delay to _pass_
|
||||
# using a truncated exponential backoff method.
|
||||
# Example: retry_delay dd_reblock_1 .1 6
|
||||
# This example will call the dd_reblock_1 function with
|
||||
# an initial delay of .1 second and call it at most 6 times
|
||||
|
||||
@@ -23,7 +23,8 @@ fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
|
||||
|
||||
# We use --local here so as to not activate
|
||||
# potentially very many remote mounts.
|
||||
mount_points=$(df --local -P 2>&1 | sed -n 's,.*[0-9]% \(/.\),\1,p')
|
||||
test -z "$mount_points" && skip_test_ "this test requires a non-root mount point"
|
||||
|
||||
@@ -60,12 +61,10 @@ inode_via_readdir()
|
||||
eval "ls -i $opts $parent_dir" | sed 's/ .*//'
|
||||
}
|
||||
|
||||
# FIXME: use a timeout, in case stat'ing mount points takes too long.
|
||||
|
||||
for dir in $mount_points; do
|
||||
readdir_inode=$(inode_via_readdir $dir)
|
||||
test $? = 77 && continue
|
||||
stat_inode=$(env stat --format=%i $dir)
|
||||
stat_inode=$(timeout 1 stat --format=%i $dir)
|
||||
# If stat fails or says the inode is 0, skip $dir.
|
||||
case $stat_inode in 0|'') continue;; esac
|
||||
test "$readdir_inode" = "$stat_inode" || fail=1
|
||||
|
||||
+12
-7
@@ -38,14 +38,19 @@ test -r /dev/stdin 2>&1 \
|
||||
|| skip_test_ '/dev/stdin is not readable'
|
||||
|
||||
mv f g < /dev/stdin > out 2>&1 & pid=$!
|
||||
sleep 1
|
||||
kill $pid
|
||||
|
||||
# Make sure out contains the prompt.
|
||||
case "`cat out`" in
|
||||
"mv: try to overwrite \`g', overriding mode 0000"*) ;;
|
||||
*) fail=1 ;;
|
||||
esac
|
||||
# Wait up to 3.1s for the expected prompt
|
||||
check_overwrite_prompt()
|
||||
{
|
||||
local delay="$1"
|
||||
case "`cat out`" in
|
||||
"mv: try to overwrite \`g', overriding mode 0000"*) ;;
|
||||
*) sleep $delay; return 1;;
|
||||
esac
|
||||
}
|
||||
retry_delay_ check_overwrite_prompt .1 5 || fail=1
|
||||
|
||||
kill $pid
|
||||
|
||||
mv -f h i > out 2>&1 || fail=1
|
||||
test -f i || fail=1
|
||||
|
||||
@@ -34,12 +34,15 @@ rm ---presume-input-tty dangle symlink &
|
||||
pid=$!
|
||||
# The buggy rm (fileutils-4.1.9) would hang here, waiting for input.
|
||||
|
||||
# Give the working rm a chance to remove the file.
|
||||
sleep 1
|
||||
|
||||
# The file must no longer exist.
|
||||
ls -l dangle > /dev/null 2>&1 && fail=1
|
||||
ls -l symlink > /dev/null 2>&1 && fail=1
|
||||
# Wait up to 3.1s for rm to remove the files
|
||||
check_files_removed() {
|
||||
local delay="$1"
|
||||
local present=0
|
||||
ls -l dangle > /dev/null 2>&1 && present=1
|
||||
ls -l symlink > /dev/null 2>&1 && present=1
|
||||
test $present = 1 && { sleep $delay; return 1; } || :
|
||||
}
|
||||
retry_delay_ check_files_removed .1 5 || fail=1
|
||||
|
||||
kill $pid > /dev/null 2>&1
|
||||
|
||||
|
||||
Reference in new issue
Block a user