[PATCH 26/40] generic/310: cleanup killing background processes

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Dave Chinner <dchinner@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 tests/generic/310 | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/tests/generic/310 b/tests/generic/310
index 1ab81dd2e..52babfdc8 100755
--- a/tests/generic/310
+++ b/tests/generic/310
@@ -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
-- 
2.45.2





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux