diff mbox series

[mickledore,meta-oe,1/1] libgpiod: modify ptest value toggle test

Message ID 20230523200144.560946-1-joe.slater@windriver.com
State New
Headers show
Series [mickledore,meta-oe,1/1] libgpiod: modify ptest value toggle test | expand

Commit Message

Slater, Joseph May 23, 2023, 8:01 p.m. UTC
From: Joe Slater <joe.slater@windriver.com>

The test "gpioset: toggle (continuous)" is modified to
sync with toggles instead of assuming a delay.

Signed-off-by: Joe Slater <joe.slater@windriver.com>
---
 ...-ptest-modify-delays-in-toggle-tests.patch | 58 +++++++++++++++++++
 .../recipes-support/libgpiod/libgpiod_2.0.bb  |  2 +
 2 files changed, 60 insertions(+)
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.0/0001-ptest-modify-delays-in-toggle-tests.patch

Comments

Randy MacLeod May 23, 2023, 8:33 p.m. UTC | #1
On 2023-05-23 16:01, joe.slater@windriver.com wrote:
> From: Joe Slater<joe.slater@windriver.com>
>
> The test "gpioset: toggle (continuous)" is modified to
> sync with toggles instead of assuming a delay.

Please send thisĀ  to meta-oe/master first.

What is this 'toggles' that you are referring to?

Maybe you can explain the problem in the commit log
as well as in the patch.

Can you send the patch to linux-gpio@vger.kernel.org
and include a link to that thread since there isn't a way
to track bugs/enhancements that I can see in:
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about/


Thanks!

../Randy


>
> Signed-off-by: Joe Slater<joe.slater@windriver.com>
> ---
>   ...-ptest-modify-delays-in-toggle-tests.patch | 58 +++++++++++++++++++
>   .../recipes-support/libgpiod/libgpiod_2.0.bb  |  2 +
>   2 files changed, 60 insertions(+)
>   create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.0/0001-ptest-modify-delays-in-toggle-tests.patch
>
> diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.0/0001-ptest-modify-delays-in-toggle-tests.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.0/0001-ptest-modify-delays-in-toggle-tests.patch
> new file mode 100644
> index 0000000000..359b4a2afa
> --- /dev/null
> +++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.0/0001-ptest-modify-delays-in-toggle-tests.patch
> @@ -0,0 +1,58 @@
> +From b73a79245ac0fa36b15bf3308e4ed008793ff15c Mon Sep 17 00:00:00 2001
> +From: Joe Slater<joe.slater@windriver.com>
> +Date: Fri, 19 May 2023 08:46:47 -0700
> +Subject: [PATCH] ptest: modify delays in toggle tests
> +
> +Try to test toggling values at their midpoints.
> +
> +Upstream-Status: pending
> +
> +Signed-off-by: Joe Slater<joe.slater@windriver.com>
> +---
> + tools/gpio-tools-test.bats | 6 +++---
> + 1 file changed, 3 insertions(+), 3 deletions(-)
> +
> +--- libgpiod-2.0.orig/tools/gpio-tools-test.bats
> ++++ libgpiod-2.0/tools/gpio-tools-test.bats
> +@@ -141,6 +141,20 @@ gpiosim_check_value() {
> + 	[ "$VAL" = "$EXPECTED" ]
> + }
> +
> ++gpiosim_wait_value() {
> ++	local OFFSET=$2
> ++	local EXPECTED=$3
> ++	local DEVNAME=${GPIOSIM_DEV_NAME[$1]}
> ++	local CHIPNAME=${GPIOSIM_CHIP_NAME[$1]}
> ++
> ++	for i in {1..10} ; do
> ++		VAL=$(<$GPIOSIM_SYSFS/$DEVNAME/$CHIPNAME/sim_gpio$OFFSET/value)
> ++		[ "$VAL" = "$EXPECTED" ] && return
> ++		sleep 0.1
> ++	done
> ++	return 1
> ++}
> ++
> + gpiosim_cleanup() {
> + 	for CHIP in ${!GPIOSIM_CHIP_NAME[@]}
> + 	do
> +@@ -1567,15 +1581,15 @@ request_release_line() {
> + 	gpiosim_check_value sim0 4 0
> + 	gpiosim_check_value sim0 7 0
> +
> +-	sleep 1
> +-
> +-	gpiosim_check_value sim0 1 0
> ++	# sleeping fixed amounts can be unreliable, so we
> ++	# sync to the toggles
> ++	#
> ++	gpiosim_wait_value sim0 1 0
> + 	gpiosim_check_value sim0 4 1
> + 	gpiosim_check_value sim0 7 1
> +
> +-	sleep 1
> +
> +-	gpiosim_check_value sim0 1 1
> ++	gpiosim_wait_value sim0 1 1
> + 	gpiosim_check_value sim0 4 0
> + 	gpiosim_check_value sim0 7 0
> + }
> diff --git a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb
> index 179fe170e2..25463e9a87 100644
> --- a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb
> +++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb
> @@ -7,6 +7,8 @@ LIC_FILES_CHKSUM = " \
>       file://LICENSES/CC-BY-SA-4.0.txt;md5=fba3b94d88bfb9b81369b869a1e9a20f  \
>   "
>   
> +SRC_URI +="file://0001-ptest-modify-delays-in-toggle-tests.patch"
> +
>   SRC_URI[sha256sum] = "f74cbf82038b3cb98ebeb25bce55ee2553be28194002d2a9889b9268cce2dd07"
>   
>   S = "${WORKDIR}/libgpiod-2.0"
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.0/0001-ptest-modify-delays-in-toggle-tests.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.0/0001-ptest-modify-delays-in-toggle-tests.patch
new file mode 100644
index 0000000000..359b4a2afa
--- /dev/null
+++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.0/0001-ptest-modify-delays-in-toggle-tests.patch
@@ -0,0 +1,58 @@ 
+From b73a79245ac0fa36b15bf3308e4ed008793ff15c Mon Sep 17 00:00:00 2001
+From: Joe Slater <joe.slater@windriver.com>
+Date: Fri, 19 May 2023 08:46:47 -0700
+Subject: [PATCH] ptest: modify delays in toggle tests
+
+Try to test toggling values at their midpoints.
+
+Upstream-Status: pending
+
+Signed-off-by: Joe Slater <joe.slater@windriver.com>
+---
+ tools/gpio-tools-test.bats | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- libgpiod-2.0.orig/tools/gpio-tools-test.bats
++++ libgpiod-2.0/tools/gpio-tools-test.bats
+@@ -141,6 +141,20 @@ gpiosim_check_value() {
+ 	[ "$VAL" = "$EXPECTED" ]
+ }
+ 
++gpiosim_wait_value() {
++	local OFFSET=$2
++	local EXPECTED=$3
++	local DEVNAME=${GPIOSIM_DEV_NAME[$1]}
++	local CHIPNAME=${GPIOSIM_CHIP_NAME[$1]}
++
++	for i in {1..10} ; do
++		VAL=$(<$GPIOSIM_SYSFS/$DEVNAME/$CHIPNAME/sim_gpio$OFFSET/value)
++		[ "$VAL" = "$EXPECTED" ] && return
++		sleep 0.1
++	done
++	return 1
++}
++
+ gpiosim_cleanup() {
+ 	for CHIP in ${!GPIOSIM_CHIP_NAME[@]}
+ 	do
+@@ -1567,15 +1581,15 @@ request_release_line() {
+ 	gpiosim_check_value sim0 4 0
+ 	gpiosim_check_value sim0 7 0
+ 
+-	sleep 1
+-
+-	gpiosim_check_value sim0 1 0
++	# sleeping fixed amounts can be unreliable, so we
++	# sync to the toggles
++	#
++	gpiosim_wait_value sim0 1 0
+ 	gpiosim_check_value sim0 4 1
+ 	gpiosim_check_value sim0 7 1
+ 
+-	sleep 1
+ 
+-	gpiosim_check_value sim0 1 1
++	gpiosim_wait_value sim0 1 1
+ 	gpiosim_check_value sim0 4 0
+ 	gpiosim_check_value sim0 7 0
+ }
diff --git a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb
index 179fe170e2..25463e9a87 100644
--- a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb
+++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.bb
@@ -7,6 +7,8 @@  LIC_FILES_CHKSUM = " \
     file://LICENSES/CC-BY-SA-4.0.txt;md5=fba3b94d88bfb9b81369b869a1e9a20f \
 "
 
+SRC_URI += "file://0001-ptest-modify-delays-in-toggle-tests.patch"
+
 SRC_URI[sha256sum] = "f74cbf82038b3cb98ebeb25bce55ee2553be28194002d2a9889b9268cce2dd07"
 
 S = "${WORKDIR}/libgpiod-2.0"