|
|
fdf7c0 |
From b7671c82010ffc04dfaecff2dd19ef8b2283e2b6 Mon Sep 17 00:00:00 2001
|
|
|
fdf7c0 |
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
|
|
fdf7c0 |
Date: Tue, 19 Jul 2022 14:48:21 +0200
|
|
|
fdf7c0 |
Subject: [PATCH 47/52] tests: add test for names
|
|
|
fdf7c0 |
|
|
|
fdf7c0 |
Current behavior is not documented and tested. This test is a base for
|
|
|
fdf7c0 |
future improvements. It is enough to test it only with native metadata,
|
|
|
fdf7c0 |
because it is generic code. Generated properties are passed to metadata
|
|
|
fdf7c0 |
handler.
|
|
|
fdf7c0 |
|
|
|
fdf7c0 |
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
|
|
fdf7c0 |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
fdf7c0 |
---
|
|
|
fdf7c0 |
tests/00createnames | 93 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
fdf7c0 |
1 file changed, 93 insertions(+)
|
|
|
fdf7c0 |
create mode 100644 tests/00createnames
|
|
|
fdf7c0 |
|
|
|
fdf7c0 |
diff --git a/tests/00createnames b/tests/00createnames
|
|
|
fdf7c0 |
new file mode 100644
|
|
|
fdf7c0 |
index 00000000..64b81b92
|
|
|
fdf7c0 |
--- /dev/null
|
|
|
fdf7c0 |
+++ b/tests/00createnames
|
|
|
fdf7c0 |
@@ -0,0 +1,93 @@
|
|
|
fdf7c0 |
+set -x -e
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+# Test how <devname> and --name= are handled for create mode.
|
|
|
fdf7c0 |
+# We need to check three properties, generated from those parameters:
|
|
|
fdf7c0 |
+# - devnode name
|
|
|
fdf7c0 |
+# - link in /dev/md/ (MD_DEVNAME property from --detail --export)
|
|
|
fdf7c0 |
+# - name in metadata (MD_NAME property from --examine --export)
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+function _verify() {
|
|
|
fdf7c0 |
+ local DEVNODE_NAME="$1"
|
|
|
fdf7c0 |
+ local WANTED_LINK="$2"
|
|
|
fdf7c0 |
+ local WANTED_NAME="$3"
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+ local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_DEVNAME)"
|
|
|
fdf7c0 |
+ if [[ "$?" != "0" ]]; then
|
|
|
fdf7c0 |
+ echo "Cannot get details for $DEVNODE_NAME - unexpected devnode."
|
|
|
fdf7c0 |
+ exit 1
|
|
|
fdf7c0 |
+ fi
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+ if [[ "$WANTED_LINK" != "empty" ]]; then
|
|
|
fdf7c0 |
+ local EXPECTED="MD_DEVNAME=$WANTED_LINK"
|
|
|
fdf7c0 |
+ if [[ "$RES" != "$EXPECTED" ]]; then
|
|
|
fdf7c0 |
+ echo "$RES doesn't match $EXPECTED."
|
|
|
fdf7c0 |
+ exit 1
|
|
|
fdf7c0 |
+ fi
|
|
|
fdf7c0 |
+ fi
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+ local RES="$(mdadm -E --export $dev0 | grep MD_NAME)"
|
|
|
fdf7c0 |
+ if [[ "$?" != "0" ]]; then
|
|
|
fdf7c0 |
+ echo "Cannot get metadata from $dev0."
|
|
|
fdf7c0 |
+ exit 1
|
|
|
fdf7c0 |
+ fi
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+ local EXPECTED="MD_NAME=$(hostname):$WANTED_NAME"
|
|
|
fdf7c0 |
+ if [[ "$RES" != "$EXPECTED" ]]; then
|
|
|
fdf7c0 |
+ echo "$RES doesn't match $EXPECTED."
|
|
|
fdf7c0 |
+ exit 1
|
|
|
fdf7c0 |
+ fi
|
|
|
fdf7c0 |
+}
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+function _create() {
|
|
|
fdf7c0 |
+ local DEVNAME=$1
|
|
|
fdf7c0 |
+ local NAME=$2
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+ if [[ -z "$NAME" ]]; then
|
|
|
fdf7c0 |
+ mdadm -CR "$DEVNAME" -l0 -n 1 $dev0 --force
|
|
|
fdf7c0 |
+ else
|
|
|
fdf7c0 |
+ mdadm -CR "$DEVNAME" --name="$NAME" -l0 -n 1 $dev0 --force
|
|
|
fdf7c0 |
+ fi
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+ if [[ "$?" != "0" ]]; then
|
|
|
fdf7c0 |
+ echo "Cannot create device."
|
|
|
fdf7c0 |
+ exit 1
|
|
|
fdf7c0 |
+ fi
|
|
|
fdf7c0 |
+}
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+# The most trivial case.
|
|
|
fdf7c0 |
+_create "/dev/md/name"
|
|
|
fdf7c0 |
+_verify "/dev/md127" "name" "name"
|
|
|
fdf7c0 |
+mdadm -S "/dev/md127"
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+_create "name"
|
|
|
fdf7c0 |
+_verify "/dev/md127" "name" "name"
|
|
|
fdf7c0 |
+mdadm -S "/dev/md127"
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+# Use 'mdX' as name.
|
|
|
fdf7c0 |
+_create "/dev/md/md0"
|
|
|
fdf7c0 |
+_verify "/dev/md127" "md0" "md0"
|
|
|
fdf7c0 |
+mdadm -S "/dev/md127"
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+_create "md0"
|
|
|
fdf7c0 |
+_verify "/dev/md127" "md0" "md0"
|
|
|
fdf7c0 |
+mdadm -S "/dev/md127"
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+# <devnode> is used to create MD_DEVNAME but, name is used to create MD_NAME.
|
|
|
fdf7c0 |
+_create "/dev/md/devnode" "name"
|
|
|
fdf7c0 |
+_verify "/dev/md127" "devnode" "name"
|
|
|
fdf7c0 |
+mdadm -S "/dev/md127"
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+_create "devnode" "name"
|
|
|
fdf7c0 |
+_verify "/dev/md127" "devnode" "name"
|
|
|
fdf7c0 |
+mdadm -S "/dev/md127"
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+# Devnode points to /dev/ directory. MD_DEVNAME doesn't exist.
|
|
|
fdf7c0 |
+_create "/dev/md0"
|
|
|
fdf7c0 |
+_verify "/dev/md0" "empty" "0"
|
|
|
fdf7c0 |
+mdadm -S "/dev/md0"
|
|
|
fdf7c0 |
+
|
|
|
fdf7c0 |
+# Devnode points to /dev/ directory and name is set.
|
|
|
fdf7c0 |
+_create "/dev/md0" "name"
|
|
|
fdf7c0 |
+_verify "/dev/md0" "empty" "name"
|
|
|
fdf7c0 |
+mdadm -S "/dev/md0"
|
|
|
fdf7c0 |
--
|
|
|
fdf7c0 |
2.31.1
|
|
|
fdf7c0 |
|