]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
generic/310: cleanup killing background processes
authorDave Chinner <dchinner@redhat.com>
Tue, 26 Nov 2024 21:00:57 +0000 (08:00 +1100)
committerZorro Lang <zlang@kernel.org>
Sun, 8 Dec 2024 14:13:25 +0000 (22:13 +0800)
Use the trick we used with fsstress of copying the binary to a test
specific name so that we can simply use pkill to reliably kill the
background processes this test runs. Also use SIGPIPE to avoid
bash from throwing out "Killed" errors.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/310

index 1ab81dd2e344a65c7f39bc698fff8a132a43013f..52babfdc803a2199467c23eb83f96451d352099f 100755 (executable)
@@ -29,11 +29,8 @@ _begin_fstest auto
 # Override the default cleanup function.
 _cleanup()
 {
-       if [ -n "$readdir_pid" ]; then
-               pkill --parent "$readdir_pid" t_readdir > /dev/null 2>&1
-               kill -9 $readdir_pid > /dev/null 2>&1
-               wait
-       fi
+       pkill -9 $seq.t_readdir > /dev/null 2>&1
+       wait
        rm -rf $TEST_DIR/tmp
        rm -f $tmp.*
 }
@@ -74,6 +71,8 @@ check_kernel_bug()
 
 RUN_TIME=$((30 * $TIME_FACTOR))
 
+cp $here/src/t_readdir_1 $TEST_DIR/$seq.t_readdir_1
+cp $here/src/t_readdir_2 $TEST_DIR/$seq.t_readdir_2
 SEQ_DIR=$TEST_DIR/$seq
 mkdir -p $SEQ_DIR
 for n in {1..4096}; do
@@ -82,12 +81,11 @@ done
 
 _test_read()
 {
-       $here/src/t_readdir_1 $SEQ_DIR > /dev/null 2>&1 &
-       readdir_pid=$!
+        $TEST_DIR/$seq.t_readdir_1 $SEQ_DIR > /dev/null 2>&1 &
        sleep $RUN_TIME
-       kill $readdir_pid
-       unset readdir_pid
+       pkill -PIPE $seq.t_readdir_1
        wait
+
        check_kernel_bug
        if [ $? -ne 0 ]; then
                _fatal "kernel bug detected, check dmesg for more infomation."
@@ -96,11 +94,10 @@ _test_read()
 
 _test_lseek()
 {
-       $here/src/t_readdir_2 $SEQ_DIR > /dev/null 2>&1 &
+       $TEST_DIR/$seq.t_readdir_2 $SEQ_DIR > /dev/null 2>&1 &
        readdir_pid=$!
        sleep $RUN_TIME
-       kill $readdir_pid
-       unset readdir_pid
+       pkill -PIPE $seq.t_readdir_2
        wait
 
        check_kernel_bug