Skip to contentSkip to conversation

tests: clear the superblock before adding a device to the array.

PATCH Applied Sudhakar Panneerselvam 2 participants 2 messages Jul 22, 2021 – Aug 2, 2021 MD RAID

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/5 tests: clear the superblock before adding a device to the array.

This fixes '02lineargrow' test as prior metadata causes --add operation to fail.

---
 test | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
test +7 -2
index 711a3c7a2076..39a85d77fa25 100755
@@ -48,7 +48,7 @@ mdadm() {
 		;;
 	esac
 	case $* in
-	*-C* | *--create* | *-B* | *--build* )
+	*-C* | *--create* | *-B* | *--build* | *--add* )
 		# clear superblock every time once creating or
 		# building arrays, because it's always creating
 		# and building array many times in a test case.
@@ -59,7 +59,12 @@ mdadm() {
 					$mdadm --zero $args > /dev/null
 			}
 		done
-		$mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes
+		if [[ $* == *--add* ]]
+		then
+			$mdadm 2> $targetdir/stderr --quiet "$@"
+		else
+			$mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes
+		fi
 		;;
 	* )
 		$mdadm 2> $targetdir/stderr --quiet "$@"
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 26 lines · Sudhakar Panneerselvam

This fixes '02lineargrow' test as prior metadata causes --add operation to fail.

---
 test | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
test +1 -1
index 711a3c7a2076..39a85d77fa25 100755
@@ -48,7 +48,7 @@ mdadm() {
 		;;
 	esac
 	case $* in
-	*-C* | *--create* | *-B* | *--build* )
+	*-C* | *--create* | *-B* | *--build* | *--add* )
 		# clear superblock every time once creating or
 		# building arrays, because it's always creating
 		# and building array many times in a test case.
@@ -59,7 +59,12 @@ mdadm() {
 					$mdadm --zero $args > /dev/null
 			}
 		done

test mdadm() { · line 70

Quoted 10 lines
test +6 -1
-		$mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes
+		if [[ $* == *--add* ]]
+		then
+			$mdadm 2> $targetdir/stderr --quiet "$@"
+		else
+			$mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes
+		fi
 		;;
 	* )
 		$mdadm 2> $targetdir/stderr --quiet "$@"

I am not sure this is the right approach to fix this. --add has two meanings and we would potentially want test cases where we make sure not to add arrays with pre-existing meta-data on them. I think it's better to fix this in 02lineargrow

Thanks,
Jes