* [PATCH v2 blktests] block/044: basic block error injection sanity test
@ 2026-06-30 11:37 Christoph Hellwig
2026-07-06 2:56 ` Shin'ichiro Kawasaki
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2026-06-30 11:37 UTC (permalink / raw)
To: shinichiro.kawasaki; +Cc: linux-block
Test the basic block layer error injection functionality.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
Changes since v1:
- change license to GPLv2 or later
- incorporate various improvements from Shin'ichiro
tests/block/044 | 62 +++++++++++++++++++++++++++++++++++++++++++++
tests/block/044.out | 9 +++++++
2 files changed, 71 insertions(+)
create mode 100755 tests/block/044
create mode 100644 tests/block/044.out
diff --git a/tests/block/044 b/tests/block/044
new file mode 100755
index 000000000000..097dd79d3bda
--- /dev/null
+++ b/tests/block/044
@@ -0,0 +1,62 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2026 Christoph Hellwig.
+#
+# Basic block error injection test.
+
+. tests/block/rc
+. common/scsi_debug
+
+DESCRIPTION="basic block error injection test"
+QUICK=1
+
+requires()
+{
+ _have_kernel_option BLK_ERROR_INJECTION
+ _have_loadable_scsi_debug
+ _have_program xfs_io
+}
+
+# load and remove scsi_debug once to test the static_key bug in the
+# initial commit
+_test_load_unload()
+{
+ if ! _init_scsi_debug dev_size_mb=500; then
+ return 1
+ fi
+ echo "Testing unload without rules"
+ _exit_scsi_debug
+}
+
+_test_rules()
+{
+ if ! _init_scsi_debug dev_size_mb=500; then
+ return 1
+ fi
+
+ local dev=${SCSI_DEBUG_DEVICES[0]}
+ local debugfs_file="/sys/kernel/debug/block/$dev/error_injection"
+
+ echo "Testing valid rules"
+ echo "add,op=WRITE,status=RESOURCE,start=0,nr_sectors=8" > "$debugfs_file"
+ echo "add,op=READ,status=IOERR,start=16,nr_sectors=8" > "$debugfs_file"
+ xfs_io -d -c 'pwrite -q 0 4096' /dev/"$dev"
+ xfs_io -d -c 'pread -q 0 4096' /dev/"$dev"
+ xfs_io -d -c 'pwrite -q 4096 4096' /dev/"$dev"
+ xfs_io -d -c 'pread -q 8192 8192' /dev/"$dev"
+
+ echo "Testing invalid rules"
+ echo "op=READ,status=IOERR" > "$debugfs_file"
+ echo "add,op=READ,status=EIO,start=32" > "$debugfs_file"
+ _exit_scsi_debug
+}
+
+test()
+{
+ echo "Running ${TEST_NAME}"
+
+ _test_load_unload
+ _test_rules
+
+ echo "Test complete"
+}
diff --git a/tests/block/044.out b/tests/block/044.out
new file mode 100644
index 000000000000..92efcddf7c8e
--- /dev/null
+++ b/tests/block/044.out
@@ -0,0 +1,9 @@
+Running block/044
+Testing unload without rules
+Testing valid rules
+pwrite: Cannot allocate memory
+pread: Input/output error
+Testing invalid rules
+tests/block/044: line 56: echo: write error: Invalid argument
+tests/block/044: line 57: echo: write error: Invalid argument
+Test complete
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-06 2:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 11:37 [PATCH v2 blktests] block/044: basic block error injection sanity test Christoph Hellwig
2026-07-06 2:56 ` Shin'ichiro Kawasaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox