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

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