nuttx-apps/testing/drivers/drivertest
Arnav Sharma b6bb99c951 testing/drivertest: add sensor watchdog regression test.
Issue apache/nuttx#20145 reported a sensor fetch-watchdog lifetime
regression: sensor_poll() arms a per-subscriber watchdog for
fetch-only sensors with a finite interval, but sensor_close()
freed the subscriber without cancelling it, letting
sensor_fetch_expired() run after free.

Fixed by apache/nuttx#20146, which cancels the watchdog on close.
Add regression coverage in drivertest as suggested by the maintainer:
open a sensor device, set a finite fetch interval, enter the poll
path so the watchdog can be armed, then close while the watchdog
state is relevant. Sleep past the interval so any stray timer would
fire, and reopen to prove teardown was clean. The test skips
gracefully when no sensor device is present, so it is safe on sim
without hardware.

The test does not deterministically reproduce the UAF; it verifies
the observable invariant that repeated poll/close/reopen cycles
complete cleanly and the device remains usable. Under KASAN or
stress, a missing wd_cancel in close would be caught here.

Impact:
* Is new feature added? YES (new regression test coverage in
  testing/drivers/drivertest, no existing functionality changed).
* Impact on user, build, hardware, documentation, security,
  compatibility? NO, test-only change.

Testing:
* Full build and runtime logs are provided in the PR description.

Assisted-by: Muse Spark:muse-spark-1.3
Assisted-by: Claude:claude-opus
Signed-off-by: Arnav Sharma <2006arnavsharma@gmail.com>
2026-09-18 21:10:56 +08:00
..
CMakeLists.txt testing/drivertest: add sensor watchdog regression test. 2026-09-18 21:10:56 +08:00
drivertest_adc.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_audio.c apps: Fix additional open() arguments. 2026-05-22 13:39:04 +08:00
drivertest_block.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_framebuffer.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
drivertest_gpio.c apps/testing:move {drivertest fftest irtest monkey nand_sim pcitest sd_bench sd_stress sensortest} folders to the new driver folder 2025-01-21 16:22:56 +08:00
drivertest_i2c_read.c apps/testing:move {drivertest fftest irtest monkey nand_sim pcitest sd_bench sd_stress sensortest} folders to the new driver folder 2025-01-21 16:22:56 +08:00
drivertest_i2c_spi.c testing: unify Private Types banners 2025-05-28 10:16:50 +08:00
drivertest_i2c_write.c apps/testing:move {drivertest fftest irtest monkey nand_sim pcitest sd_bench sd_stress sensortest} folders to the new driver folder 2025-01-21 16:22:56 +08:00
drivertest_lcd.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
drivertest_mps2.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_mps2_isr_signal.c apps/testing:move {drivertest fftest irtest monkey nand_sim pcitest sd_bench sd_stress sensortest} folders to the new driver folder 2025-01-21 16:22:56 +08:00
drivertest_mps2_zerointerrupt.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_oneshot.c !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-22 13:38:25 +08:00
drivertest_pm.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_pm_runtime.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_pm_smp.c testing/pm_smp: add more delay, avoid idle canot run one cycle 2025-12-01 19:10:11 +08:00
drivertest_posix_timer.c !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-22 13:38:25 +08:00
drivertest_pwm.c testing/drivertest_pwm: remove references to CONFIG_PWM_MULTICHAN 2026-05-18 11:35:09 -04:00
drivertest_regulator.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_relay.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_rtc.c testing/drivers: set default vendor dalay to 1 for rtc cases run correctly 2026-02-03 17:36:49 +08:00
drivertest_sensor.c testing/drivertest: add sensor watchdog regression test. 2026-09-18 21:10:56 +08:00
drivertest_simple.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_timer.c testing/drivers/drivertest: Uniform test case name 2025-03-27 09:00:15 +01:00
drivertest_touchpanel.c testing: add unistd.h for drivertest_touchpanel.c 2026-01-26 19:32:27 +08:00
drivertest_uart.c drivertest_uart: uart device open should use cfmakeraw to ensure raw. 2025-12-01 19:09:41 +08:00
drivertest_watchdog.c testing/drivers: add watchdog notifier cmocka coverage 2026-07-21 15:37:01 -03:00
Kconfig apps/testing:move {drivertest fftest irtest monkey nand_sim pcitest sd_bench sd_stress sensortest} folders to the new driver folder 2025-01-21 16:22:56 +08:00
Make.defs apps/testing:move {drivertest fftest irtest monkey nand_sim pcitest sd_bench sd_stress sensortest} folders to the new driver folder 2025-01-21 16:22:56 +08:00
Makefile testing/drivertest: add sensor watchdog regression test. 2026-09-18 21:10:56 +08:00
test_content_gen.py apps/testing:move {drivertest fftest irtest monkey nand_sim pcitest sd_bench sd_stress sensortest} folders to the new driver folder 2025-01-21 16:22:56 +08:00