Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: core: include scsi_lib KUnit tests in modular builds
@ 2026-12-04  2:03 Pengpeng Hou
  2026-12-04  2:16 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-12-04  2:03 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: linux-scsi, Pengpeng Hou, Geert Uytterhoeven, Bart Van Assche,
	linux-kselftest

The SCSI library tests are included from scsi_lib.c rather than built as
a separate module. Selecting the test as m therefore defines the module
form of the option, which the existing ifdef ignores.

Use IS_REACHABLE at the inclusion site. This enables the tests for a
modular SCSI host with modular tests without making built-in SCSI
reference module-only tests.

The issue was found by our static-analysis tool and manually reviewed.

Fixes: 25a1f7a0a1fe ("scsi: core: Add kunit tests for scsi_check_passthrough()")
Fixes: f7c7190f49b8 ("scsi: core: Really include kunit tests with SCSI_LIB_KUNIT_TEST")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
Geert previously proposed a separate SCSI test module. This fix keeps
the tests in scsi_lib and needs no exported SCSI helper. It does not
enable independent loading of these tests.
https://lore.kernel.org/r/48ca5e827ca420bbdbabb1643e2179dc95c9e0b7.1710849638.git.geert@linux-m68k.org

The patch was prepared with Gemini and revised with Codex assistance
(Assisted-by: gpt 5).

Built scsi_lib.o on x86-64 with GCC 11.4 and W=1, with KUNIT=m and
SCSI_LIB_KUNIT_TEST=m. With SCSI=m the suite was absent before and
present after the change. With SCSI=y it remained excluded after the
change. The suite was not executed.

 drivers/scsi/scsi_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ab39514cc0c6bd485e424f103619c692e710ca7b..948918803831907488f0ccf68b741f4b2f902f0a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -3611,6 +3611,6 @@ void scsi_set_sense(struct scsi_cmnd *scmd, int desc, u8 key, u16 code)
 }
 EXPORT_SYMBOL_GPL(scsi_set_sense);
 
-#ifdef CONFIG_SCSI_LIB_KUNIT_TEST
+#if IS_REACHABLE(CONFIG_SCSI_LIB_KUNIT_TEST)
 #include "scsi_lib_test.c"
 #endif

base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04  2:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  2:03 [PATCH] scsi: core: include scsi_lib KUnit tests in modular builds Pengpeng Hou
2026-12-04  2:16 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox