]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
tests/dm: add dm test group and a test for self-map
authorYu Kuai <yukuai3@huawei.com>
Thu, 27 Apr 2023 02:41:26 +0000 (10:41 +0800)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 5 May 2023 00:27:57 +0000 (09:27 +0900)
Verify that reload a dm with maps to itself will fail.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
[Shin'ichiro: improved code for shellcheck, commit title and file mode]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
tests/dm/001 [new file with mode: 0755]
tests/dm/001.out [new file with mode: 0644]
tests/dm/rc [new file with mode: 0644]

diff --git a/tests/dm/001 b/tests/dm/001
new file mode 100755 (executable)
index 0000000..f69f30f
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2023 Yu Kuai
+#
+# Regression test for commit 077a4033541f ("block: don't allow a disk link
+# holder to itself")
+
+. tests/dm/rc
+
+DESCRIPTION="reload a dm with maps to itself"
+QUICK=1
+
+requires() {
+       _have_kver 6 2
+}
+
+test_device() {
+       echo "Running ${TEST_NAME}"
+
+       dmsetup create test --table "0 8192 linear ${TEST_DEV} 0"
+       dmsetup suspend test
+       if dmsetup reload test --table "0 8192 linear /dev/mapper/test 0" \
+          &> /dev/null; then
+               echo "reload a dm with maps to itself succeed."
+       fi
+       dmsetup remove test
+
+       echo "Test complete"
+}
diff --git a/tests/dm/001.out b/tests/dm/001.out
new file mode 100644 (file)
index 0000000..4bd2c08
--- /dev/null
@@ -0,0 +1,2 @@
+Running dm/001
+Test complete
diff --git a/tests/dm/rc b/tests/dm/rc
new file mode 100644 (file)
index 0000000..0486db0
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2023 Yu Kuai
+#
+# Tests for device-mapper
+
+. common/rc
+
+group_requires() {
+       _have_root
+       _have_program dmsetup
+       _have_driver dm-mod
+}