blob: 11f2d5c4a973807e324921f901de08fd6ce8952b [file] [log] [blame]
Patrick Williamse760df82023-05-26 11:10:49 -05001From b73a79245ac0fa36b15bf3308e4ed008793ff15c Mon Sep 17 00:00:00 2001
2From: Joe Slater <joe.slater@windriver.com>
3Date: Fri, 19 May 2023 08:46:47 -0700
4Subject: [PATCH] ptest: modify delays in toggle test
5
6The test "gpioset: toggle (continuous)" uses fixed delays to test
7toggling values. This is not reliable, so we switch to looking
8for transitions from one value to another.
9
10Upstream-Status: pending
11
12Signed-off-by: Joe Slater <joe.slater@windriver.com>
13---
14 tools/gpio-tools-test.bats | 6 +++---
15 1 file changed, 3 insertions(+), 3 deletions(-)
16
17--- libgpiod-2.0.orig/tools/gpio-tools-test.bats
18+++ libgpiod-2.0/tools/gpio-tools-test.bats
19@@ -141,6 +141,20 @@ gpiosim_check_value() {
20 [ "$VAL" = "$EXPECTED" ]
21 }
22
23+gpiosim_wait_value() {
24+ local OFFSET=$2
25+ local EXPECTED=$3
26+ local DEVNAME=${GPIOSIM_DEV_NAME[$1]}
27+ local CHIPNAME=${GPIOSIM_CHIP_NAME[$1]}
28+
29+ for i in {1..10} ; do
30+ VAL=$(<$GPIOSIM_SYSFS/$DEVNAME/$CHIPNAME/sim_gpio$OFFSET/value)
31+ [ "$VAL" = "$EXPECTED" ] && return
32+ sleep 0.1
33+ done
34+ return 1
35+}
36+
37 gpiosim_cleanup() {
38 for CHIP in ${!GPIOSIM_CHIP_NAME[@]}
39 do
40@@ -1567,15 +1581,15 @@ request_release_line() {
41 gpiosim_check_value sim0 4 0
42 gpiosim_check_value sim0 7 0
43
44- sleep 1
45-
46- gpiosim_check_value sim0 1 0
47+ # sleeping fixed amounts can be unreliable, so we
48+ # sync to the toggles
49+ #
50+ gpiosim_wait_value sim0 1 0
51 gpiosim_check_value sim0 4 1
52 gpiosim_check_value sim0 7 1
53
54- sleep 1
55
56- gpiosim_check_value sim0 1 1
57+ gpiosim_wait_value sim0 1 1
58 gpiosim_check_value sim0 4 0
59 gpiosim_check_value sim0 7 0
60 }