diff options
-rwxr-xr-x | test | 5 | ||||
-rw-r--r-- | tests/func.sh | 13 | ||||
-rw-r--r-- | tests/templates/names_template | 14 |
3 files changed, 30 insertions, 2 deletions
@@ -11,6 +11,11 @@ system_speed_limit_min=0 test_speed_limit_min=100 test_speed_limit_max=500 devlist= +# If super1 metadata name doesn't have the same hostname with machine, +# it's treated as foreign. +# For example, /dev/md0 is created, stops it, then assemble it, the +# device node will be /dev/md127 (127 is choosed by mdadm autumatically) +is_foreign="no" savelogs=0 exitonerror=1 diff --git a/tests/func.sh b/tests/func.sh index 221cff15..cfe83e55 100644 --- a/tests/func.sh +++ b/tests/func.sh @@ -153,6 +153,18 @@ restore_system_speed_limit() { echo $system_speed_limit_max > /proc/sys/dev/raid/speed_limit_max } +is_raid_foreign() { + + # If the length of hostname is >= 32, super1 doesn't use + # hostname in metadata + hostname=$(hostname) + if [ `expr length $(hostname)` -lt 32 ]; then + is_foreign="no" + else + is_foreign="yes" + fi +} + do_setup() { trap cleanup 0 1 3 15 trap ctrl_c 2 @@ -232,6 +244,7 @@ do_setup() { [ -f /proc/mdstat ] || modprobe md_mod echo 0 > /sys/module/md_mod/parameters/start_ro record_system_speed_limit + is_raid_foreign } # check various things diff --git a/tests/templates/names_template b/tests/templates/names_template index 1b6cd14b..88ad5b8c 100644 --- a/tests/templates/names_template +++ b/tests/templates/names_template @@ -30,6 +30,7 @@ function names_verify() { local DEVNODE_NAME="$1" local WANTED_LINK="$2" local WANTED_NAME="$3" + local EXPECTED="" local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_DEVNAME)" if [[ "$?" != "0" ]]; then @@ -38,7 +39,12 @@ function names_verify() { fi if [[ "$WANTED_LINK" != "empty" ]]; then - local EXPECTED="MD_DEVNAME=$WANTED_LINK" + EXPECTED="MD_DEVNAME=$WANTED_LINK" + + if [ ! -b /dev/md/$WANTED_LINK ]; then + echo "/dev/md/$WANTED_LINK doesn't exit" + exit 1 + fi fi if [[ "$RES" != "$EXPECTED" ]]; then @@ -52,7 +58,11 @@ function names_verify() { exit 1 fi - local EXPECTED="MD_NAME=$(hostname):$WANTED_NAME" + if [ $is_foreign == "no" ]; then + EXPECTED="MD_NAME=$(hostname):$WANTED_NAME" + else + EXPECTED="MD_NAME=$WANTED_NAME" + fi if [[ "$RES" != "$EXPECTED" ]]; then echo "$RES doesn't match $EXPECTED." exit 1 |