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

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