diff mbox series

tests/dm: add dm-dust general functionality test

Message ID 20240520155826.23446-1-bgurney@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests/dm: add dm-dust general functionality test | expand

Commit Message

Bryan Gurney May 20, 2024, 3:58 p.m. UTC
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.

Signed-off-by: Bryan Gurney <bgurney@redhat.com>
---
 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

Comments

Shinichiro Kawasaki May 21, 2024, 5:16 a.m. UTC | #1
On May 20, 2024 / 11:58, Bryan Gurney wrote:
> 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.
> 
> Signed-off-by: Bryan Gurney <bgurney@redhat.com>

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.
Shinichiro Kawasaki May 27, 2024, 7:48 a.m. UTC | #2
On May 21, 2024 / 05:16, Shinichiro Kawasaki wrote:
> On May 20, 2024 / 11:58, Bryan Gurney wrote:
> > 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.
> > 
> > Signed-off-by: Bryan Gurney <bgurney@redhat.com>
> 
> 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!
diff mbox series

Patch

diff --git a/tests/dm/002 b/tests/dm/002
new file mode 100755
index 0000000..6635c43
--- /dev/null
+++ b/tests/dm/002
@@ -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"
+}
diff --git a/tests/dm/002.out b/tests/dm/002.out
new file mode 100644
index 0000000..f348fe4
--- /dev/null
+++ b/tests/dm/002.out
@@ -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