diff options
author | Joe Slater <joe.slater@windriver.com> | 2023-06-15 15:04:10 -0700 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2023-06-17 13:15:52 -0400 |
commit | 6e9118383c62a38f313e9bc3d19fa79b70c12cf2 (patch) | |
tree | b274570a8793b3e481f657ed4781ad258be96bc5 | |
parent | 7649dfaedf9f56b63b93dbf0d08fc3fedf2b79b2 (diff) | |
download | meta-openembedded-6e9118383c62a38f313e9bc3d19fa79b70c12cf2.tar.gz |
libgpiod: modify test 'gpioset: toggle (continuous)'
Look for level transitions when testing toggling
values because using fixed delays to assume value
changes is not reliable.
Signed-off-by: Joe Slater <joe.slater@windriver.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
cherry-pick from meta-oe/master 45a8bb2620...
Signed-off-by: Joe Slater <joe.slater@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | meta-oe/recipes-support/libgpiod/libgpiod-2.0/gpio-tools-test-bats-modify.patch | 67 | ||||
-rw-r--r-- | meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb | 2 |
2 files changed, 69 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.0/gpio-tools-test-bats-modify.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.0/gpio-tools-test-bats-modify.patch new file mode 100644 index 0000000000..4d49467968 --- /dev/null +++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.0/gpio-tools-test-bats-modify.patch | |||
@@ -0,0 +1,67 @@ | |||
1 | From 53f9670d6af1bd0745c1df9c469b269c72607b23 Mon Sep 17 00:00:00 2001 | ||
2 | From: Joe Slater <joe.slater@windriver.com> | ||
3 | Date: Tue, 6 Jun 2023 08:04:27 -0700 | ||
4 | Subject: [PATCH] tools: tests: modify delays in toggle test | ||
5 | |||
6 | The test "gpioset: toggle (continuous)" uses fixed delays to test | ||
7 | toggling values. This is not reliable, so we switch to looking | ||
8 | for transitions from one value to another. | ||
9 | |||
10 | We wait for a transition up to 1.5 seconds. | ||
11 | |||
12 | Signed-off-by: Joe Slater <joe.slater@windriver.com> | ||
13 | Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | ||
14 | |||
15 | Upstream-status: accepted | ||
16 | |||
17 | Signed-off-by: Joe Slater <joe.slater@windriver.com> | ||
18 | --- | ||
19 | tools/gpio-tools-test.bats | 21 ++++++++++++++++----- | ||
20 | 1 file changed, 16 insertions(+), 5 deletions(-) | ||
21 | |||
22 | diff --git a/tools/gpio-tools-test.bats b/tools/gpio-tools-test.bats | ||
23 | index c83ca7d..929c35a 100755 | ||
24 | --- a/tools/gpio-tools-test.bats | ||
25 | +++ b/tools/gpio-tools-test.bats | ||
26 | @@ -141,6 +141,20 @@ gpiosim_check_value() { | ||
27 | [ "$VAL" = "$EXPECTED" ] | ||
28 | } | ||
29 | |||
30 | +gpiosim_wait_value() { | ||
31 | + local OFFSET=$2 | ||
32 | + local EXPECTED=$3 | ||
33 | + local DEVNAME=${GPIOSIM_DEV_NAME[$1]} | ||
34 | + local CHIPNAME=${GPIOSIM_CHIP_NAME[$1]} | ||
35 | + local PORT=$GPIOSIM_SYSFS/$DEVNAME/$CHIPNAME/sim_gpio$OFFSET/value | ||
36 | + | ||
37 | + for i in {1..15}; do | ||
38 | + [ "$(<$PORT)" = "$EXPECTED" ] && return | ||
39 | + sleep 0.1 | ||
40 | + done | ||
41 | + return 1 | ||
42 | +} | ||
43 | + | ||
44 | gpiosim_cleanup() { | ||
45 | for CHIP in ${!GPIOSIM_CHIP_NAME[@]} | ||
46 | do | ||
47 | @@ -1567,15 +1581,12 @@ request_release_line() { | ||
48 | gpiosim_check_value sim0 4 0 | ||
49 | gpiosim_check_value sim0 7 0 | ||
50 | |||
51 | - sleep 1 | ||
52 | - | ||
53 | - gpiosim_check_value sim0 1 0 | ||
54 | + gpiosim_wait_value sim0 1 0 | ||
55 | gpiosim_check_value sim0 4 1 | ||
56 | gpiosim_check_value sim0 7 1 | ||
57 | |||
58 | - sleep 1 | ||
59 | |||
60 | - gpiosim_check_value sim0 1 1 | ||
61 | + gpiosim_wait_value sim0 1 1 | ||
62 | gpiosim_check_value sim0 4 0 | ||
63 | gpiosim_check_value sim0 7 0 | ||
64 | } | ||
65 | -- | ||
66 | 2.25.1 | ||
67 | |||
diff --git a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb index 179fe170e2..ee20aaf792 100644 --- a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb +++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb | |||
@@ -11,6 +11,8 @@ SRC_URI[sha256sum] = "f74cbf82038b3cb98ebeb25bce55ee2553be28194002d2a9889b9268cc | |||
11 | 11 | ||
12 | S = "${WORKDIR}/libgpiod-2.0" | 12 | S = "${WORKDIR}/libgpiod-2.0" |
13 | 13 | ||
14 | SRC_URI += "file://gpio-tools-test-bats-modify.patch" | ||
15 | |||
14 | # We must enable gpioset-interactive for all gpio-tools tests to pass | 16 | # We must enable gpioset-interactive for all gpio-tools tests to pass |
15 | PACKAGECONFIG[tests] = "--enable-tests --enable-gpioset-interactive,--disable-tests,kmod util-linux glib-2.0 catch2 libedit" | 17 | PACKAGECONFIG[tests] = "--enable-tests --enable-gpioset-interactive,--disable-tests,kmod util-linux glib-2.0 catch2 libedit" |
16 | PACKAGECONFIG[gpioset-interactive] = "--enable-gpioset-interactive,--disable-gpioset-interactive,libedit" | 18 | PACKAGECONFIG[gpioset-interactive] = "--enable-gpioset-interactive,--disable-gpioset-interactive,libedit" |