diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/init.cfg | 3 | ||||
-rwxr-xr-x | tests/ls/readdir-mountpoint-inode | 7 | ||||
-rwxr-xr-x | tests/mv/i-3 | 19 | ||||
-rwxr-xr-x | tests/rm/dangling-symlink | 15 |
4 files changed, 26 insertions, 18 deletions
diff --git a/tests/init.cfg b/tests/init.cfg index 6c0ffd948..1048cf39d 100644 --- a/tests/init.cfg +++ b/tests/init.cfg @@ -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 diff --git a/tests/ls/readdir-mountpoint-inode b/tests/ls/readdir-mountpoint-inode index 63378b64c..d03ba06f9 100755 --- a/tests/ls/readdir-mountpoint-inode +++ b/tests/ls/readdir-mountpoint-inode @@ -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 diff --git a/tests/mv/i-3 b/tests/mv/i-3 index 4201dfbca..78a252664 100755 --- a/tests/mv/i-3 +++ b/tests/mv/i-3 @@ -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 diff --git a/tests/rm/dangling-symlink b/tests/rm/dangling-symlink index 9a3cfd631..270459c5b 100755 --- a/tests/rm/dangling-symlink +++ b/tests/rm/dangling-symlink @@ -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 |