From: Alessandro Carminati <[email protected]> Introduce a dedicated Kconfig option to enable extended KUnit testing for /dev/mem behavior.
The option enables tests covering I/O memory access restrictions, including behavior under CONFIG_IO_STRICT_DEVMEM. Because the tests may perform reads from I/O regions, they are opt-in and documented with appropriate warnings. This keeps test coverage explicit and avoids unintended hardware side effects. Signed-off-by: Alessandro Carminati <[email protected]> --- drivers/char/Kconfig | 21 +++++++++++++++++++++ drivers/char/Makefile | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index d2cfc584e202..cd3e47b47f44 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -317,6 +317,27 @@ config DEVMEM memory. When in doubt, say "Y". +config DEVMEM_KUNIT_TEST + tristate "KUnit tests for /dev/mem" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + Enables in-kernel unit tests for /dev/mem read/write logic. + +config DEVMEM_KUNIT_TEST_IO + bool "KUnit tests for /dev/mem extended to I/O space" + depends on DEVMEM_KUNIT_TEST + default n + help + Extend KUnit tests for devmem to cover IO space. + When CONFIG_IO_STRICT_DEVMEM is enabled, the kernel denies + access to claimed IO regions. Enabling this option adds two + KUnit test cases to verify this behavior. + Note: These tests perform read operations, which can have + side effects on certain hardware. + Enable this only if you are certain your hardware handles + unsolicited reads safely. + config NVRAM tristate "/dev/nvram support" depends on X86 || HAVE_ARCH_NVRAM_OPS diff --git a/drivers/char/Makefile b/drivers/char/Makefile index 1291369b9126..176f2b8f98dc 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -4,6 +4,7 @@ # obj-y += mem.o random.o +obj-$(CONFIG_DEVMEM_KUNIT_TEST) += mem_kunit_test.o obj-$(CONFIG_TTY_PRINTK) += ttyprintk.o obj-y += misc.o obj-$(CONFIG_TEST_MISC_MINOR) += misc_minor_kunit.o -- 2.48.1
