]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/test: Add a mode to repeat specified tests
authorLogan Gunthorpe <logang@deltatee.com>
Wed, 22 Jun 2022 20:25:17 +0000 (14:25 -0600)
committerJes Sorensen <jes@trained-monkey.org>
Sun, 7 Aug 2022 20:27:59 +0000 (16:27 -0400)
Many tests fail infrequently or rarely. To help find these, add
an option to run the tests multiple times by specifying --loop=N.

If --loop=0 is specified, the test will be looped forever.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
test

diff --git a/test b/test
index 711a3c7a2076d100ad908543a8b4935fa6882f56..da6db5e0f6317d3793abaf4c7f02d9bf4fdcad9a 100755 (executable)
--- a/test
+++ b/test
@@ -10,6 +10,7 @@ devlist=
 
 savelogs=0
 exitonerror=1
+loop=1
 prefix='[0-9][0-9]'
 
 # use loop devices by default if doesn't specify --dev
@@ -117,6 +118,7 @@ do_help() {
                --logdir=directory          Directory to save all logfiles in
                --save-logs                 Usually use with --logdir together
                --keep-going | --no-error   Don't stop on error, ie. run all tests
+               --loop=N                    Run tests N times (0 to run forever)
                --dev=loop|lvm|ram|disk     Use loop devices (default), LVM, RAM or disk
                --disks=                    Provide a bunch of physical devices for test
                --volgroup=name             LVM volume group for LVM test
@@ -211,6 +213,9 @@ parse_args() {
                --keep-going | --no-error )
                        exitonerror=0
                        ;;
+               --loop=* )
+                       loop="${i##*=}"
+                       ;;
                --disable-multipath )
                        unset MULTIPATH
                        ;;
@@ -263,19 +268,26 @@ main() {
        echo "Testing on linux-$(uname -r) kernel"
        [ "$savelogs" == "1" ] &&
                echo "Saving logs to $logdir"
-       if [ "x$TESTLIST" != "x" ]
-       then
-               for script in ${TESTLIST[@]}
-               do
-                       do_test $testdir/$script
-               done
-       else
-               for script in $testdir/$prefix $testdir/$prefix*[^~]
-               do
-                       do_test $script
-               done
-       fi
 
+       while true; do
+               if [ "x$TESTLIST" != "x" ]
+               then
+                       for script in ${TESTLIST[@]}
+                       do
+                               do_test $testdir/$script
+                       done
+               else
+                       for script in $testdir/$prefix $testdir/$prefix*[^~]
+                       do
+                               do_test $script
+                       done
+               fi
+
+               let loop=$loop-1
+               if [ "$loop" == "0" ]; then
+                       break
+               fi
+       done
        exit 0
 }