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

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