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>
--- /dev/null
+#!/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"
+}
--- /dev/null
+Running dm/001
+Test complete
--- /dev/null
+#!/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
+}