Blame SOURCES/0043-mdadm-test-Mark-and-ignore-broken-test-failures.patch

cd8c44
From 28520bf114b3b0515a48ff44fff4ecbe9ed6dfad Mon Sep 17 00:00:00 2001
cd8c44
From: Logan Gunthorpe <logang@deltatee.com>
cd8c44
Date: Wed, 22 Jun 2022 14:25:18 -0600
2b63fb
Subject: [PATCH 43/83] mdadm/test: Mark and ignore broken test failures
cd8c44
cd8c44
Add functionality to continue if a test marked as broken fails.
cd8c44
cd8c44
To mark a test as broken, a file with the same name but with the suffix
cd8c44
'.broken' should exist. The first line in the file will be printed with
cd8c44
a KNOWN BROKEN message; the rest of the file can describe the how the
cd8c44
test is broken.
cd8c44
cd8c44
Also adds --skip-broken and --skip-always-broken to skip all the tests
cd8c44
that have a .broken file or to skip all tests whose .broken file's first
cd8c44
line contains the keyword always.
cd8c44
cd8c44
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
cd8c44
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
cd8c44
---
cd8c44
 test | 37 +++++++++++++++++++++++++++++++++++--
cd8c44
 1 file changed, 35 insertions(+), 2 deletions(-)
cd8c44
cd8c44
diff --git a/test b/test
cd8c44
index da6db5e0..61d9ee83 100755
cd8c44
--- a/test
cd8c44
+++ b/test
cd8c44
@@ -10,6 +10,8 @@ devlist=
cd8c44
 
cd8c44
 savelogs=0
cd8c44
 exitonerror=1
cd8c44
+ctrl_c_error=0
cd8c44
+skipbroken=0
cd8c44
 loop=1
cd8c44
 prefix='[0-9][0-9]'
cd8c44
 
cd8c44
@@ -36,6 +38,7 @@ die() {
cd8c44
 
cd8c44
 ctrl_c() {
cd8c44
 	exitonerror=1
cd8c44
+	ctrl_c_error=1
cd8c44
 }
cd8c44
 
cd8c44
 # mdadm always adds --quiet, and we want to see any unexpected messages
cd8c44
@@ -80,8 +83,21 @@ mdadm() {
cd8c44
 do_test() {
cd8c44
 	_script=$1
cd8c44
 	_basename=`basename $_script`
cd8c44
+	_broken=0
cd8c44
+
cd8c44
 	if [ -f "$_script" ]
cd8c44
 	then
cd8c44
+		if [ -f "${_script}.broken" ]; then
cd8c44
+			_broken=1
cd8c44
+			_broken_msg=$(head -n1 "${_script}.broken" | tr -d '\n')
cd8c44
+			if [ "$skipbroken" == "all" ]; then
cd8c44
+				return
cd8c44
+			elif [ "$skipbroken" == "always" ] &&
cd8c44
+			     [[ "$_broken_msg" == *always* ]]; then
cd8c44
+				return
cd8c44
+			fi
cd8c44
+		fi
cd8c44
+
cd8c44
 		rm -f $targetdir/stderr
cd8c44
 		# this might have been reset: restore the default.
cd8c44
 		echo 2000 > /proc/sys/dev/raid/speed_limit_max
cd8c44
@@ -98,10 +114,15 @@ do_test() {
cd8c44
 		else
cd8c44
 			save_log fail
cd8c44
 			_fail=1
cd8c44
+			if [ "$_broken" == "1" ]; then
cd8c44
+				echo "  (KNOWN BROKEN TEST: $_broken_msg)"
cd8c44
+			fi
cd8c44
 		fi
cd8c44
 		[ "$savelogs" == "1" ] &&
cd8c44
 			mv -f $targetdir/log $logdir/$_basename.log
cd8c44
-		[ "$_fail" == "1" -a "$exitonerror" == "1" ] && exit 1
cd8c44
+		[ "$ctrl_c_error" == "1" ] && exit 1
cd8c44
+		[ "$_fail" == "1" -a "$exitonerror" == "1" \
cd8c44
+		  -a "$_broken" == "0" ] && exit 1
cd8c44
 	fi
cd8c44
 }
cd8c44
 
cd8c44
@@ -119,6 +140,8 @@ do_help() {
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
+		--skip-broken               Skip tests that are known to be broken
cd8c44
+		--skip-always-broken        Skip tests that are known to always fail
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
@@ -216,6 +239,12 @@ parse_args() {
cd8c44
 		--loop=* )
cd8c44
 			loop="${i##*=}"
cd8c44
 			;;
cd8c44
+		--skip-broken )
cd8c44
+			skipbroken=all
cd8c44
+			;;
cd8c44
+		--skip-always-broken )
cd8c44
+			skipbroken=always
cd8c44
+			;;
cd8c44
 		--disable-multipath )
cd8c44
 			unset MULTIPATH
cd8c44
 			;;
cd8c44
@@ -279,7 +308,11 @@ main() {
cd8c44
 		else
cd8c44
 			for script in $testdir/$prefix $testdir/$prefix*[^~]
cd8c44
 			do
cd8c44
-				do_test $script
cd8c44
+				case $script in
cd8c44
+				 *.broken) ;;
cd8c44
+				 *)
cd8c44
+				     do_test $script
cd8c44
+				 esac
cd8c44
 			done
cd8c44
 		fi
cd8c44
 
cd8c44
-- 
2b63fb
2.38.1
cd8c44