Blame SOURCES/0042-mdadm-test-Add-a-mode-to-repeat-specified-tests.patch

cd8c44
From a7bfcc716e235664dfb3b6c5a9590273e611ac72 Mon Sep 17 00:00:00 2001
cd8c44
From: Logan Gunthorpe <logang@deltatee.com>
cd8c44
Date: Wed, 22 Jun 2022 14:25:17 -0600
2b63fb
Subject: [PATCH 42/83] mdadm/test: Add a mode to repeat specified tests
cd8c44
cd8c44
Many tests fail infrequently or rarely. To help find these, add
cd8c44
an option to run the tests multiple times by specifying --loop=N.
cd8c44
cd8c44
If --loop=0 is specified, the test will be looped forever.
cd8c44
cd8c44
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
cd8c44
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
cd8c44
---
cd8c44
 test | 36 ++++++++++++++++++++++++------------
cd8c44
 1 file changed, 24 insertions(+), 12 deletions(-)
cd8c44
cd8c44
diff --git a/test b/test
cd8c44
index 711a3c7a..da6db5e0 100755
cd8c44
--- a/test
cd8c44
+++ b/test
cd8c44
@@ -10,6 +10,7 @@ devlist=
cd8c44
 
cd8c44
 savelogs=0
cd8c44
 exitonerror=1
cd8c44
+loop=1
cd8c44
 prefix='[0-9][0-9]'
cd8c44
 
cd8c44
 # use loop devices by default if doesn't specify --dev
cd8c44
@@ -117,6 +118,7 @@ do_help() {
cd8c44
 		--logdir=directory          Directory to save all logfiles in
cd8c44
 		--save-logs                 Usually use with --logdir together
cd8c44
 		--keep-going | --no-error   Don't stop on error, ie. run all tests
cd8c44
+		--loop=N                    Run tests N times (0 to run forever)
cd8c44
 		--dev=loop|lvm|ram|disk     Use loop devices (default), LVM, RAM or disk
cd8c44
 		--disks=                    Provide a bunch of physical devices for test
cd8c44
 		--volgroup=name             LVM volume group for LVM test
cd8c44
@@ -211,6 +213,9 @@ parse_args() {
cd8c44
 		--keep-going | --no-error )
cd8c44
 			exitonerror=0
cd8c44
 			;;
cd8c44
+		--loop=* )
cd8c44
+			loop="${i##*=}"
cd8c44
+			;;
cd8c44
 		--disable-multipath )
cd8c44
 			unset MULTIPATH
cd8c44
 			;;
cd8c44
@@ -263,19 +268,26 @@ main() {
cd8c44
 	echo "Testing on linux-$(uname -r) kernel"
cd8c44
 	[ "$savelogs" == "1" ] &&
cd8c44
 		echo "Saving logs to $logdir"
cd8c44
-	if [ "x$TESTLIST" != "x" ]
cd8c44
-	then
cd8c44
-		for script in ${TESTLIST[@]}
cd8c44
-		do
cd8c44
-			do_test $testdir/$script
cd8c44
-		done
cd8c44
-	else
cd8c44
-		for script in $testdir/$prefix $testdir/$prefix*[^~]
cd8c44
-		do
cd8c44
-			do_test $script
cd8c44
-		done
cd8c44
-	fi
cd8c44
 
cd8c44
+	while true; do
cd8c44
+		if [ "x$TESTLIST" != "x" ]
cd8c44
+		then
cd8c44
+			for script in ${TESTLIST[@]}
cd8c44
+			do
cd8c44
+				do_test $testdir/$script
cd8c44
+			done
cd8c44
+		else
cd8c44
+			for script in $testdir/$prefix $testdir/$prefix*[^~]
cd8c44
+			do
cd8c44
+				do_test $script
cd8c44
+			done
cd8c44
+		fi
cd8c44
+
cd8c44
+		let loop=$loop-1
cd8c44
+		if [ "$loop" == "0" ]; then
cd8c44
+			break
cd8c44
+		fi
cd8c44
+	done
cd8c44
 	exit 0
cd8c44
 }
cd8c44
 
cd8c44
-- 
2b63fb
2.38.1
cd8c44