blob: c55bfb125b2ee9322aa0846fae6b4324b5967a8a [file] [log] [blame]
Andrew Geissler8f840682023-07-21 09:09:43 -05001From feab1f72fcf032a4d21d0a69eb61b23a5ddb3352 Mon Sep 17 00:00:00 2001
2From: Logan Gunthorpe <logang@deltatee.com>
3Date: Wed, 22 Jun 2022 14:25:18 -0600
4Subject: [PATCH 5/6] mdadm/test: Mark and ignore broken test failures
5
6Add functionality to continue if a test marked as broken fails.
7
8To mark a test as broken, a file with the same name but with the suffix
9'.broken' should exist. The first line in the file will be printed with
10a KNOWN BROKEN message; the rest of the file can describe the how the
11test is broken.
12
13Also adds --skip-broken and --skip-always-broken to skip all the tests
14that have a .broken file or to skip all tests whose .broken file's first
15line contains the keyword always.
16
17Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
18Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
19
20Upstream-Status: Backport
21
22Reference to upstream patch:
23https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=28520bf114b3
24
25[OP: adjusted context for mdadm-4.2]
26Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
27---
28 test | 37 +++++++++++++++++++++++++++++++++++--
29 1 file changed, 35 insertions(+), 2 deletions(-)
30
31diff --git a/test b/test
32index 8f189d9..ee8fba1 100755
33--- a/test
34+++ b/test
35@@ -10,6 +10,8 @@ devlist=
36
37 savelogs=0
38 exitonerror=1
39+ctrl_c_error=0
40+skipbroken=0
41 prefix='[0-9][0-9]'
42
43 # use loop devices by default if doesn't specify --dev
44@@ -35,6 +37,7 @@ die() {
45
46 ctrl_c() {
47 exitonerror=1
48+ ctrl_c_error=1
49 }
50
51 # mdadm always adds --quiet, and we want to see any unexpected messages
52@@ -79,8 +82,21 @@ mdadm() {
53 do_test() {
54 _script=$1
55 _basename=`basename $_script`
56+ _broken=0
57+
58 if [ -f "$_script" ]
59 then
60+ if [ -f "${_script}.broken" ]; then
61+ _broken=1
62+ _broken_msg=$(head -n1 "${_script}.broken" | tr -d '\n')
63+ if [ "$skipbroken" == "all" ]; then
64+ return
65+ elif [ "$skipbroken" == "always" ] &&
66+ [[ "$_broken_msg" == *always* ]]; then
67+ return
68+ fi
69+ fi
70+
71 rm -f $targetdir/stderr
72 # this might have been reset: restore the default.
73 echo 2000 > /proc/sys/dev/raid/speed_limit_max
74@@ -97,10 +113,15 @@ do_test() {
75 else
76 save_log fail
77 _fail=1
78+ if [ "$_broken" == "1" ]; then
79+ echo " (KNOWN BROKEN TEST: $_broken_msg)"
80+ fi
81 fi
82 [ "$savelogs" == "1" ] &&
83 mv -f $targetdir/log $logdir/$_basename.log
84- [ "$_fail" == "1" -a "$exitonerror" == "1" ] && exit 1
85+ [ "$ctrl_c_error" == "1" ] && exit 1
86+ [ "$_fail" == "1" -a "$exitonerror" == "1" \
87+ -a "$_broken" == "0" ] && exit 1
88 fi
89 }
90
91@@ -117,6 +138,8 @@ do_help() {
92 --logdir=directory Directory to save all logfiles in
93 --save-logs Usually use with --logdir together
94 --keep-going | --no-error Don't stop on error, ie. run all tests
95+ --skip-broken Skip tests that are known to be broken
96+ --skip-always-broken Skip tests that are known to always fail
97 --dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk
98 --disks= Provide a bunch of physical devices for test
99 --volgroup=name LVM volume group for LVM test
100@@ -211,6 +234,12 @@ parse_args() {
101 --keep-going | --no-error )
102 exitonerror=0
103 ;;
104+ --skip-broken )
105+ skipbroken=all
106+ ;;
107+ --skip-always-broken )
108+ skipbroken=always
109+ ;;
110 --disable-multipath )
111 unset MULTIPATH
112 ;;
113@@ -275,7 +304,11 @@ main() {
114 if [ $script == "$testdir/11spare-migration" ];then
115 continue
116 fi
117- do_test $script
118+ case $script in
119+ *.broken) ;;
120+ *)
121+ do_test $script
122+ esac
123 done
124 fi
125
126--
1272.39.1
128