Skip to contentSkip to conversation

leds: Provide skeleton KUnit testing for the LEDs framework

PATCH Applied Lee Jones 1 participant 2 messages Apr 24, 2025 – Apr 30, 2025 LED

lore
Share & tools
lore

Lee Jones

author maintainer
#0 lore raw

PATCH 1/1 leds: Provide skeleton KUnit testing for the LEDs framework

Apply a very basic implementation of KUnit LED testing.

More tests / use-cases will be added steadily over time.

CMD:
tools/testing/kunit/kunit.py run --kunitconfig drivers/leds

OUTPUT:
[15:34:19] Configuring KUnit Kernel ...
[15:34:19] Building KUnit Kernel ...
Populating config with:

  $ make ARCH=um O=.kunit olddefconfig
  Building with:
  $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=20
  [15:34:22] Starting KUnit Kernel (1/1)...
  [15:34:22] ============================================================
  Running tests with:
  $ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
  [15:34:23] ===================== led (1 subtest) ======================
  [15:34:23] [PASSED] led_test_class_register
  [15:34:23] ======================= [PASSED] led =======================
  [15:34:23] ============================================================
  [15:34:23] Testing complete. Ran 1 tests: passed: 1
  [15:34:23] Elapsed time: 4.268s total, 0.001s configuring, 3.048s building, 1.214s running
---
 drivers/leds/.kunitconfig |  4 +++
 drivers/leds/Kconfig      |  7 ++++
 drivers/leds/Makefile     |  1 +
 drivers/leds/led-test.c   | 76 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 88 insertions(+)
 create mode 100644 drivers/leds/.kunitconfig
 create mode 100644 drivers/leds/led-test.c
drivers/leds/.kunitconfig new file +4 -0
new file mode 100644
index 000000000000..5180f77910a1
@@ -0,0 +1,4 @@
+CONFIG_KUNIT=y
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_KUNIT_TEST=y
drivers/leds/Kconfig +7 -0
index a104cbb0a001..c3684b148f18 100644
@@ -55,6 +55,13 @@ config LEDS_BRIGHTNESS_HW_CHANGED
 
 	  See Documentation/ABI/testing/sysfs-class-led for details.
 
+config LEDS_KUNIT_TEST
+	tristate "KUnit tests for LEDs"
+	depends on KUNIT && LEDS_CLASS
+	default KUNIT_ALL_TESTS
+	help
+	  Say Y here to enable KUnit testing for the LEDs framework.
+
 comment "LED drivers"
 
 config LEDS_88PM860X
drivers/leds/Makefile +1 -0
index 2f170d69dcbf..9a0333ec1a86 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_LEDS_CLASS)		+= led-class.o
 obj-$(CONFIG_LEDS_CLASS_FLASH)		+= led-class-flash.o
 obj-$(CONFIG_LEDS_CLASS_MULTICOLOR)	+= led-class-multicolor.o
 obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
+obj-$(CONFIG_LEDS_KUNIT_TEST)		+= led-test.o
 
 # LED Platform Drivers (keep this sorted, M-| sort)
 obj-$(CONFIG_LEDS_88PM860X)		+= leds-88pm860x.o
drivers/leds/led-test.c new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.49.0.901.g37484f566f-goog
author maintainer Applied
#1 lore raw

Re: (subset) [PATCH 1/1] leds: Provide skeleton KUnit testing for the LEDs framework

Quoted 8 lines · Lee Jones

Apply a very basic implementation of KUnit LED testing.

More tests / use-cases will be added steadily over time.

CMD:
tools/testing/kunit/kunit.py run --kunitconfig drivers/leds

[...]

Applied, thanks!

[1/1] leds: Provide skeleton KUnit testing for the LEDs framework

      commit: 72a3aadde656a6df096221c3d7fecb76ccb5619f

--
Lee Jones [李琼斯]