]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
tests: fix "foreign" verification for nameing tests.
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Fri, 22 Nov 2024 09:27:35 +0000 (10:27 +0100)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Mon, 25 Nov 2024 08:43:33 +0000 (09:43 +0100)
Mdadm supports DEVNODE in multiple form, we cannot trust that because it
does not always reflect name in metadata. Tests are defining clear
expectations- we must use them.

Do foreign verification against WANTED_NAME instead of passed DEVNODE.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
tests/func.sh
tests/templates/names_template

index 214773bbd70c221f48f8565114a58886c11883e6..4b4d374916b2d5db7fc58a282eca3713399cb0a2 100644 (file)
@@ -186,7 +186,7 @@ is_raid_foreign() {
        # to decide if an array is foreign or local. It adds homehost if
        # one array is local
        hostname=$(hostname)
-       if [ `expr length "$(hostname)$name"` -lt 31 ]; then
+       if [ `expr length "$(hostname):$name"` -lt 31 ]; then
                is_foreign="no"
        else
                is_foreign="yes"
index c94245eaab2a716da7fe6d920ea8ab8e6c8eb405..8060794f5842b3a4b128acc9e5edd76e52b52d57 100644 (file)
@@ -4,8 +4,6 @@ function names_create() {
        local NAME=$2
        local NEG_TEST=$3
 
-       is_raid_foreign $DEVNAME
-
        if [[ -z "$NAME" ]]; then
                mdadm -CR "$DEVNAME" -l0 -n 1 $dev0 --force
        else
@@ -34,6 +32,10 @@ function names_verify() {
        local WANTED_NAME="$3"
        local EXPECTED=""
 
+       # We don't know what is saved in metadata, but we know what to expect. Therfore check if
+       # expecation would be foreign (no hostname information).
+       is_raid_foreign $WANTED_NAME
+
        local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_DEVNAME)"
        if [[ "$?" != "0" ]]; then
                echo "Cannot get details for $DEVNODE_NAME - unexpected devnode."