diff mbox series

[meta-oe,02/55] libgpiod: Fix intermittent gpiocli monitor ptest failure

Message ID 20261125080732.2419614-8-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-multimedia] clightd: Port ALS sensor to libiio 1.0 | expand

Commit Message

Khem Raj Nov. 25, 2026, 8:06 a.m. UTC
test_monitor_all_lines_on_request toggles line 1 twice, with line 4 in
between, before reading any event. gpio-sim delivers both changes of
line 1 as one interrupt when they happen before it is handled, so the
rising edge is lost:

  ASSERT: '41610700648 falling "foo" 41610665414 rising  4' did not
  match '[0-9]+ rising\s+"foo"'

Wait for each event before triggering the next one. In a qemux86-64
guest this took the test from 12 of 20 runs failing to none.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...for-each-event-in-test_monitor_all_l.patch | 53 +++++++++++++++++++
 .../libgpiod/libgpiod_2.3.2.bb                |  1 +
 2 files changed, 54 insertions(+)
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-dbus-tests-wait-for-each-event-in-test_monitor_all_l.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-dbus-tests-wait-for-each-event-in-test_monitor_all_l.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-dbus-tests-wait-for-each-event-in-test_monitor_all_l.patch
new file mode 100644
index 0000000000..f3eac65455
--- /dev/null
+++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-dbus-tests-wait-for-each-event-in-test_monitor_all_l.patch
@@ -0,0 +1,53 @@ 
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 28 Oct 2026 07:55:33 -0700
+Subject: [PATCH] dbus: tests: wait for each event in
+ test_monitor_all_lines_on_request
+
+The test pulls line 1 up, line 4 up and line 1 down again in quick
+succession and only then reads the monitor output. gpio-sim raises the
+line interrupts through irq_sim, so two changes of the same line that
+happen before the interrupt is handled are delivered as one interrupt,
+and as edge detection is set to both edges the kernel derives the edge
+type from the line value read in the handler. The rising edge on line 1
+is then lost and only a falling edge is reported, timestamped after the
+rising edge on line 4:
+
+  ASSERT: '41610700648 falling "foo" 41610665414 rising  4' did not
+  match '[0-9]+ rising\s+"foo"'
+
+This fails intermittently, in 12 of 20 runs in a qemux86-64 guest.
+
+Wait for each event before triggering the next one, like the gpiomon
+tests in gpio-tools-test.bash do.
+
+Upstream-Status: Submitted [https://lore.kernel.org/linux-gpio/20261125080045.2410076-1-raj.khem@gmail.com/]
+AI-Generated: Uses Claude Code
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ dbus/client/gpiocli-test.bash | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/dbus/client/gpiocli-test.bash b/dbus/client/gpiocli-test.bash
+index 5160f57..ede69c9 100755
+--- a/dbus/client/gpiocli-test.bash
++++ b/dbus/client/gpiocli-test.bash
+@@ -1421,13 +1421,13 @@ test_monitor_all_lines_on_request() {
+ 	dut_run gpiocli monitor -r "$request"
+ 
+ 	gpiosim_set_pull sim0 1 pull-up
++	dut_regex_match "[0-9]+ rising\\s+\"foo\""
++
+ 	gpiosim_set_pull sim0 4 pull-up
+-	gpiosim_set_pull sim0 1 pull-down
++	dut_regex_match "[0-9]+ rising\\s+4"
+ 
+-	dut_read
+-	output_regex_match "[0-9]+ rising\\s+\"foo\""
+-	output_regex_match "[0-9]+ rising\\s+4"
+-	output_regex_match "[0-9]+ falling\\s+\"foo\""
++	gpiosim_set_pull sim0 1 pull-down
++	dut_regex_match "[0-9]+ falling\\s+\"foo\""
+ 
+ 	gpiodbus_release_request "$request"
+ }
diff --git a/meta-oe/recipes-support/libgpiod/libgpiod_2.3.2.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.3.2.bb
index eb1c454f8c..b77ca581a9 100644
--- a/meta-oe/recipes-support/libgpiod/libgpiod_2.3.2.bb
+++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.3.2.bb
@@ -25,6 +25,7 @@  FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}-2.x:"
 
 SRC_URI += " \
     file://gpio-manager.init \
+    file://0001-dbus-tests-wait-for-each-event-in-test_monitor_all_l.patch \
 "
 
 SRC_URI[sha256sum] = "dc48fb87cd72019745acb201599caf559556b5d913844df0ed011067d19e9a6b"