summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-11-22 10:27:35 +0100
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-11-25 09:43:33 +0100
commiteb24054faa67750a37e29037cb0ab9cbfdf0174c (patch)
tree34d81d5eed553e93a678a72794be068c59be0cc2
parentplatform-intel: fix buffer overflow (diff)
downloadmdadm-eb24054faa67750a37e29037cb0ab9cbfdf0174c.tar.xz
mdadm-eb24054faa67750a37e29037cb0ab9cbfdf0174c.zip
tests: fix "foreign" verification for nameing tests.
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>
-rw-r--r--tests/func.sh2
-rw-r--r--tests/templates/names_template6
2 files changed, 5 insertions, 3 deletions
diff --git a/tests/func.sh b/tests/func.sh
index 214773bb..4b4d3749 100644
--- a/tests/func.sh
+++ b/tests/func.sh
@@ -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"
diff --git a/tests/templates/names_template b/tests/templates/names_template
index c94245ea..8060794f 100644
--- a/tests/templates/names_template
+++ b/tests/templates/names_template
@@ -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."