]> granicus.if.org Git - zfs/commitdiff
ZTS: fix spurious failures in mv_files
authorchrisrd <chris@onthe.net.au>
Fri, 2 Mar 2018 17:57:29 +0000 (04:57 +1100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 2 Mar 2018 17:57:29 +0000 (09:57 -0800)
The test could fail because of a race condition between the files being
generated in the background and attempting to move the files. Wait for
all file generation to complete before trying to move the files around.

Also, clean up the waiting: the 'wait' command without arguments waits
for all child pids.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Dunlop <chris@onthe.net.au>
Closes #7220
Closes #7242
Closes #7258

tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib

index c48c07d8d02afe4dc846e0a0708c54d456dcf6db..6728e950bd31af7c1e500990e8d0a7d422bf6441 100644 (file)
@@ -108,16 +108,6 @@ function init_setup
 
 }
 
-function wait_pid
-{
-       for pid in $1
-       do
-               ps -e | grep $pid >/dev/null 2>&1
-               (( $? == 0 )) && wait $pid
-        done
-}
-
-
 #
 # Generate given number files in a
 # directory of zfs file system
@@ -141,18 +131,17 @@ function generate_files
                 cp /etc/passwd $1/file_$count \
                          > /dev/null 2>&1 &
 
-                PIDS="$PIDS $!"
+                (( proc_num = proc_num + 1 ))
 
-                proc_num=`echo $PIDS | wc -w`
                 if (( proc_num >= GANGPIDS )); then
-                        wait_pid "$PIDS"
+                        wait
                         proc_num=0
-                        PIDS=""
                 fi
 
                (( count = count + 1 ))
         done
 
+        wait
 }
 
 #