lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250826-tty-tests-v1-1-e904a817df92@gmail.com>
Date: Tue, 26 Aug 2025 16:51:31 -0600
From: Abhinav Saxena <xandfury@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
 Jiri Slaby <jirislaby@...nel.org>, Nathan Chancellor <nathan@...nel.org>, 
 Nick Desaulniers <nick.desaulniers+lkml@...il.com>, 
 Bill Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>, 
 Kees Cook <kees@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org, 
 llvm@...ts.linux.dev, linux-hardening@...r.kernel.org, 
 Abhinav Saxena <xandfury@...il.com>
Subject: [RFC PATCH 1/5] tty: Add KUnit test infrastructure configuration

Add Kconfig and Makefile support for TTY KUnit testing framework.
Introduces CONFIG_TTY_GCOV_PROFILE for targeted coverage analysis
and CONFIG_TTY_KUNIT_TESTS for test infrastructure enabling.

The infrastructure allows selective testing of TTY components without
instrumenting the entire kernel, improving development efficiency for
TTY subsystem changes.

Signed-off-by: Abhinav Saxena <xandfury@...il.com>
---
 drivers/tty/Kconfig            |  9 +++++++++
 drivers/tty/Makefile           |  7 +++++++
 drivers/tty/tests/.kunitconfig | 44 ++++++++++++++++++++++++++++++++++++++++++
 drivers/tty/tests/Kconfig      | 44 ++++++++++++++++++++++++++++++++++++++++++
 drivers/tty/tests/Makefile     |  2 ++
 5 files changed, 106 insertions(+)

diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig
index 149f3d53b76086cd4ac5acf116ebe36d816664ac..92d27761e1543ceb138a670194480ed1e711124b 100644
--- a/drivers/tty/Kconfig
+++ b/drivers/tty/Kconfig
@@ -424,6 +424,15 @@ config RPMSG_TTY
 	  To compile this driver as a module, choose M here: the module will be
 	  called rpmsg_tty.
 
+config TTY_GCOV_PROFILE
+	bool "Enable gcov profiling for TTY subsystem"
+	depends on GCOV_KERNEL && TTY
+	help
+	  Instrument drivers/tty/* with gcov when GCOV is enabled.
+	  Useful for targeted coverage runs without profiling the whole kernel.
+
+source "drivers/tty/tests/Kconfig"
+
 endif # TTY
 
 source "drivers/tty/serdev/Kconfig"
diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile
index 07aca5184a55dd38036587c3485ba9f12d2e7ec7..c0cb47c32e94abe072f4cd7e2023480bbb5da9f2 100644
--- a/drivers/tty/Makefile
+++ b/drivers/tty/Makefile
@@ -29,3 +29,10 @@ obj-$(CONFIG_VCC)		+= vcc.o
 obj-$(CONFIG_RPMSG_TTY)		+= rpmsg_tty.o
 
 obj-y += ipwireless/
+
+obj-$(CONFIG_TTY_KUNIT_TESTS) += tests/
+
+# tty profiling & coverage
+ifdef CONFIG_TTY_GCOV_PROFILE
+GCOV_PROFILE := y
+endif
diff --git a/drivers/tty/tests/.kunitconfig b/drivers/tty/tests/.kunitconfig
new file mode 100644
index 0000000000000000000000000000000000000000..a29112fa03ae78e096d9e22546b3cfd3007d710c
--- /dev/null
+++ b/drivers/tty/tests/.kunitconfig
@@ -0,0 +1,44 @@
+# TTY KUnit Test Configuration
+# =============================
+#
+# Running test with something like this:
+# -------------------------------------
+# ./tools/testing/kunit/kunit.py run tty_io_core \
+#     --kunitconfig=.kunit/ \
+#     --kunitconfig=drivers/tty/tests/.kunitconfig \
+#     --jobs "$(nproc)" \
+#     --arch=x86_64 \
+#     --make_options="LLVM=-18"
+
+# Core KUnit Infrastructure
+# -------------------------
+CONFIG_KUNIT=y
+CONFIG_KUNIT_DEBUGFS=y
+CONFIG_KUNIT_TEST=y
+CONFIG_PROC_FS=y
+CONFIG_SYSFS=y
+CONFIG_DEBUG_FS=y
+
+# TTY Subsystem Core
+# ------------------
+CONFIG_TTY=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_SERIAL_CORE=y
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+
+# TTY Drivers for Testing
+# -----------------------
+# Enable ttynull driver (required for ttynull tests)
+CONFIG_NULL_TTY=y
+
+# TTY KUnit Tests
+# ---------------
+CONFIG_TTY_KUNIT_TESTS=y
+CONFIG_TTY_KUNIT_CORE_TESTS=y
+CONFIG_TTY_KUNIT_NULL_TTY_TESTS=y
+
+# Code Coverage
+# -------------------------------------------
+CONFIG_GCOV_KERNEL=y
+CONFIG_TTY_GCOV_PROFILE=y
diff --git a/drivers/tty/tests/Kconfig b/drivers/tty/tests/Kconfig
new file mode 100644
index 0000000000000000000000000000000000000000..6012f4ab7f1bc90d434d69ee82e87e89c1291763
--- /dev/null
+++ b/drivers/tty/tests/Kconfig
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: GPL-2.0
+menu "TTY KUnit tests"
+	depends on KUNIT && TTY
+
+config TTY_KUNIT_TESTS
+	bool "TTY KUnit test infrastructure"
+	depends on KUNIT && TTY
+	default KUNIT_ALL_TESTS
+	help
+	  Enable KUnit test infrastructure for TTY drivers.
+
+	  This enables test helper functions that are included directly
+	  into tty_io.c to provide access to internal TTY functions for
+	  testing. The helpers are only available when KUNIT is enabled.
+
+	  This option provides the foundation for TTY testing but does not
+	  run any tests by itself. Enable specific test suites below.
+
+config TTY_KUNIT_CORE_TESTS
+	bool "TTY core functionality tests"
+	depends on TTY_KUNIT_TESTS
+	default KUNIT_ALL_TESTS
+	help
+	  Enable KUnit tests for TTY core functionality.
+
+	  Tests cover basic TTY operations including open/close lifecycle,
+	  write operations, buffer management, line discipline integration,
+	  and error handling through real kernel code paths.
+
+	  If unsure, say N.
+
+config TTY_KUNIT_NULL_TTY_TESTS
+	tristate "TTY null driver tests" if !KUNIT_ALL_TESTS
+	depends on TTY_KUNIT_TESTS && NULL_TTY
+	default KUNIT_ALL_TESTS
+	help
+	  Enable KUnit tests for the TTY null driver.
+
+	  Tests validate ttynull behavior as a data sink, including write
+	  operations, data discarding, and error handling. The ttynull
+	  driver discards all written data while providing minimal overhead.
+
+	  If unsure, say N.
+endmenu
diff --git a/drivers/tty/tests/Makefile b/drivers/tty/tests/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..854911a0f87d6a6fdc826cc40f99afb1202afd46
--- /dev/null
+++ b/drivers/tty/tests/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_TTY_KUNIT_CORE_TESTS) += tty_mock.o test_tty_io_core.o

-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ