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

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