Skip to contentSkip to conversation

tests/dm: add dm-dust general functionality test

PATCH Applied Bryan Gurney 2 participants 3 messages May 20, 2024 – May 27, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/dm: add dm-dust general functionality test

Add a general functionality test for the dm-dust device-mapper test target. Test the addition of bad blocks, and the clearing of bad blocks after a write is performed to the test device.

---
 tests/dm/002     | 40 ++++++++++++++++++++++++++++++++++++++++
 tests/dm/002.out | 10 ++++++++++
 2 files changed, 50 insertions(+)
 create mode 100755 tests/dm/002
 create mode 100644 tests/dm/002.out
tests/dm/002 new file +40 -0
new file mode 100755
index 0000000..6635c43
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Red Hat, Inc.
+#
+
+. tests/dm/rc
+
+DESCRIPTION="dm-dust general functionality test"
+QUICK=1
+
+requires() {
+        _have_driver dm_dust
+}
+
+
+test_device() {
+	echo "Running ${TEST_NAME}"
+
+	TEST_DEV_SZ=$(blockdev --getsz "$TEST_DEV")
+	dmsetup create dust1 --table "0 $TEST_DEV_SZ dust $TEST_DEV 0 512"
+	dmsetup message dust1 0 addbadblock 60
+	dmsetup message dust1 0 addbadblock 67
+	dmsetup message dust1 0 addbadblock 72
+	dmsetup message dust1 0 countbadblocks
+	dmsetup message dust1 0 listbadblocks
+	dmsetup message dust1 0 clearbadblocks
+	dmsetup message dust1 0 countbadblocks
+	dmsetup message dust1 0 addbadblock 60
+	dmsetup message dust1 0 addbadblock 67
+	dmsetup message dust1 0 addbadblock 72
+	dmsetup message dust1 0 countbadblocks
+	dmsetup message dust1 0 enable
+	dd if=/dev/zero of=/dev/mapper/dust1 bs=512 count=128 oflag=direct >/dev/null 2>&1 || return $?
+	sync
+	dmsetup message dust1 0 countbadblocks
+	sync
+	dmsetup remove dust1
+
+	echo "Test complete"
+}
tests/dm/002.out new file +10 -0
new file mode 100644
index 0000000..f348fe4
@@ -0,0 +1,10 @@
+Running dm/002
+countbadblocks: 3 badblock(s) found
+60
+67
+72
+dust_clear_badblocks: badblocks cleared
+countbadblocks: 0 badblock(s) found
+countbadblocks: 3 badblock(s) found
+countbadblocks: 0 badblock(s) found
+Test complete
Signature · 1 line
2.45.0
#1 lore raw
Quoted 5 lines · Bryan Gurney

Add a general functionality test for the dm-dust device-mapper test target. Test the addition of bad blocks, and the clearing of bad blocks after a write is performed to the test device.

Hi Bryan, thank you for this blktests patch. It looks good to me. I ran the the new test case on my test node and result looks good too :)

Before applying it, I will leave it for several days in case anyone have some more comments.

#2 lore raw
Quoted 5 lines · Shinichiro Kawasaki
Quoted 4 lines · Bryan Gurney

Add a general functionality test for the dm-dust device-mapper test target. Test the addition of bad blocks, and the clearing of bad blocks after a write is performed to the test device.

Quoted 7 lines
Quoted 1 line

Hi Bryan, thank you for this blktests patch. It looks good to me. I ran the the new test case on my test node and result looks good too :)

Before applying it, I will leave it for several days in case anyone have some more comments.

I've applied it. Thanks!