diff mbox series

[meta-oe,1/1] libgpiod: modify test 'gpioset: toggle (continuous)'

Message ID 20230524181131.3890392-1-joe.slater@windriver.com
State Under Review
Headers show
Series [meta-oe,1/1] libgpiod: modify test 'gpioset: toggle (continuous)' | expand

Commit Message

Slater, Joseph May 24, 2023, 6:11 p.m. UTC
From: Joe Slater <joe.slater@windriver.com>

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>
---
 ...-ptest-modify-delays-in-toggle-tests.patch | 60 +++++++++++++++++++
 .../libgpiod/libgpiod_2.0.1.bb                |  2 +
 2 files changed, 62 insertions(+)
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch

Comments

Randy MacLeod May 24, 2023, 7:46 p.m. UTC | #1
On 2023-05-24 14:11, joe.slater@windriver.com wrote:
> From: Joe Slater<joe.slater@windriver.com>
>
> Look for level transitions when testing toggling
> values because using fixed delays to assume value
> changes is not reliable.

The updated commit log and comment below look good to me.


Please send a patch to upstream and reply to this thread with
a link to that or send a commit to update the:

Upstream-Status: pending

tag.

Thanks,

../Randy

> Signed-off-by: Joe Slater<joe.slater@windriver.com>
> ---
>   ...-ptest-modify-delays-in-toggle-tests.patch | 60 +++++++++++++++++++
>   .../libgpiod/libgpiod_2.0.1.bb                |  2 +
>   2 files changed, 62 insertions(+)
>   create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
>
> diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> new file mode 100644
> index 0000000000..11f2d5c4a9
> --- /dev/null
> +++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> @@ -0,0 +1,60 @@
> +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 test
> +
> +The test "gpioset: toggle (continuous)" uses fixed delays to test
> +toggling values.  This is not reliable, so we switch to looking
> +for transitions from one value to another.
> +
> +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.1.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> index 337554cd89..91c4d27692 100644
> --- a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> +++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> @@ -9,6 +9,8 @@ LIC_FILES_CHKSUM = " \
>   
>   FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}-2.x:"
>   
> +SRC_URI +="file://0001-ptest-modify-delays-in-toggle-tests.patch"
> +
>   SRC_URI[sha256sum] = "b5367d28d045b36007a4ffd42cceda4c358737ef4f2ce22b0c1d05ec57a38392"
>   
>   # Enable all project features for ptest
Bartosz Golaszewski June 1, 2023, 7:04 p.m. UTC | #2
On Wed, May 24, 2023 at 9:46 PM Randy MacLeod via
lists.openembedded.org
<randy.macleod=windriver.com@lists.openembedded.org> wrote:
>
> On 2023-05-24 14:11, joe.slater@windriver.com wrote:
>
> From: Joe Slater <joe.slater@windriver.com>
>
> Look for level transitions when testing toggling
> values because using fixed delays to assume value
> changes is not reliable.
>
> The updated commit log and comment below look good to me.
>
>
> Please send a patch to upstream and reply to this thread with
> a link to that or send a commit to update the:
>
> Upstream-Status: pending
>

This patch breaks the following test for me:

 ✗ gpioset: toggle (continuous)
   (from function `gpiosim_wait_value' in file
/usr/lib/libgpiod/ptest/tests/gpio-tools-test.bats, line 155,
    in test file /usr/lib/libgpiod/ptest/tests/gpio-tools-test.bats, line 1587)
     `gpiosim_wait_value sim0 1 0' failed

on current master meta-openembedded. Why did this even get here? The
patch did not go upstream in this form and needs some more work.
Please Cc me on future patches to any of the libgpiod recipes.

In the meantime. Khem: could you please revert this?

Bart

> tag.
>
> Thanks,
>
> ../Randy
>
> Signed-off-by: Joe Slater <joe.slater@windriver.com>
> ---
>  ...-ptest-modify-delays-in-toggle-tests.patch | 60 +++++++++++++++++++
>  .../libgpiod/libgpiod_2.0.1.bb                |  2 +
>  2 files changed, 62 insertions(+)
>  create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
>
> diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> new file mode 100644
> index 0000000000..11f2d5c4a9
> --- /dev/null
> +++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> @@ -0,0 +1,60 @@
> +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 test
> +
> +The test "gpioset: toggle (continuous)" uses fixed delays to test
> +toggling values.  This is not reliable, so we switch to looking
> +for transitions from one value to another.
> +
> +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.1.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> index 337554cd89..91c4d27692 100644
> --- a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> +++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> @@ -9,6 +9,8 @@ LIC_FILES_CHKSUM = " \
>
>  FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}-2.x:"
>
> +SRC_URI += "file://0001-ptest-modify-delays-in-toggle-tests.patch"
> +
>  SRC_URI[sha256sum] = "b5367d28d045b36007a4ffd42cceda4c358737ef4f2ce22b0c1d05ec57a38392"
>
>  # Enable all project features for ptest
>
>
> --
> # Randy MacLeod
> # Wind River Linux
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#102793): https://lists.openembedded.org/g/openembedded-devel/message/102793
> Mute This Topic: https://lists.openembedded.org/mt/99114621/3618139
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [brgl@bgdev.pl]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj June 1, 2023, 7:14 p.m. UTC | #3
On Thu, Jun 1, 2023 at 12:04 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> On Wed, May 24, 2023 at 9:46 PM Randy MacLeod via
> lists.openembedded.org
> <randy.macleod=windriver.com@lists.openembedded.org> wrote:
> >
> > On 2023-05-24 14:11, joe.slater@windriver.com wrote:
> >
> > From: Joe Slater <joe.slater@windriver.com>
> >
> > Look for level transitions when testing toggling
> > values because using fixed delays to assume value
> > changes is not reliable.
> >
> > The updated commit log and comment below look good to me.
> >
> >
> > Please send a patch to upstream and reply to this thread with
> > a link to that or send a commit to update the:
> >
> > Upstream-Status: pending
> >
>
> This patch breaks the following test for me:
>
>  ✗ gpioset: toggle (continuous)
>    (from function `gpiosim_wait_value' in file
> /usr/lib/libgpiod/ptest/tests/gpio-tools-test.bats, line 155,
>     in test file /usr/lib/libgpiod/ptest/tests/gpio-tools-test.bats, line 1587)
>      `gpiosim_wait_value sim0 1 0' failed
>
> on current master meta-openembedded. Why did this even get here?

It was reviewed and request to upstream was also made.

We now have ptests runs for meta-oe but on a subset of recipes and they are
run regularly as part of testing. So perhaps it will be good to enable
ptests for
this and add it to PTESTS_FAST_META_OE in
meta-oe/conf/include/ptest-packagelists-meta-oe.inc
currently this recipe is part of PTESTS_PROBLEMS_META_OE which means
tests are not ready to be enabled, it will be good to sort this out for future.

The
> patch did not go upstream in this form and needs some more work.
> Please Cc me on future patches to any of the libgpiod recipes.
>

Thanks for signing up although I am not sure how to make it visible,
perhaps it would be good to
add maintainer info in the recipe header in standard way.

> In the meantime. Khem: could you please revert this?
>

Yes we can.

> Bart
>
> > tag.
> >
> > Thanks,
> >
> > ../Randy
> >
> > Signed-off-by: Joe Slater <joe.slater@windriver.com>
> > ---
> >  ...-ptest-modify-delays-in-toggle-tests.patch | 60 +++++++++++++++++++
> >  .../libgpiod/libgpiod_2.0.1.bb                |  2 +
> >  2 files changed, 62 insertions(+)
> >  create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> >
> > diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> > new file mode 100644
> > index 0000000000..11f2d5c4a9
> > --- /dev/null
> > +++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> > @@ -0,0 +1,60 @@
> > +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 test
> > +
> > +The test "gpioset: toggle (continuous)" uses fixed delays to test
> > +toggling values.  This is not reliable, so we switch to looking
> > +for transitions from one value to another.
> > +
> > +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.1.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> > index 337554cd89..91c4d27692 100644
> > --- a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> > +++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> > @@ -9,6 +9,8 @@ LIC_FILES_CHKSUM = " \
> >
> >  FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}-2.x:"
> >
> > +SRC_URI += "file://0001-ptest-modify-delays-in-toggle-tests.patch"
> > +
> >  SRC_URI[sha256sum] = "b5367d28d045b36007a4ffd42cceda4c358737ef4f2ce22b0c1d05ec57a38392"
> >
> >  # Enable all project features for ptest
> >
> >
> > --
> > # Randy MacLeod
> > # Wind River Linux
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#102793): https://lists.openembedded.org/g/openembedded-devel/message/102793
> > Mute This Topic: https://lists.openembedded.org/mt/99114621/3618139
> > Group Owner: openembedded-devel+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [brgl@bgdev.pl]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
Bartosz Golaszewski June 1, 2023, 7:20 p.m. UTC | #4
On Thu, Jun 1, 2023 at 9:15 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> On Thu, Jun 1, 2023 at 12:04 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > On Wed, May 24, 2023 at 9:46 PM Randy MacLeod via
> > lists.openembedded.org
> > <randy.macleod=windriver.com@lists.openembedded.org> wrote:
> > >
> > > On 2023-05-24 14:11, joe.slater@windriver.com wrote:
> > >
> > > From: Joe Slater <joe.slater@windriver.com>
> > >
> > > Look for level transitions when testing toggling
> > > values because using fixed delays to assume value
> > > changes is not reliable.
> > >
> > > The updated commit log and comment below look good to me.
> > >
> > >
> > > Please send a patch to upstream and reply to this thread with
> > > a link to that or send a commit to update the:
> > >
> > > Upstream-Status: pending
> > >
> >
> > This patch breaks the following test for me:
> >
> >  ✗ gpioset: toggle (continuous)
> >    (from function `gpiosim_wait_value' in file
> > /usr/lib/libgpiod/ptest/tests/gpio-tools-test.bats, line 155,
> >     in test file /usr/lib/libgpiod/ptest/tests/gpio-tools-test.bats, line 1587)
> >      `gpiosim_wait_value sim0 1 0' failed
> >
> > on current master meta-openembedded. Why did this even get here?
>
> It was reviewed and request to upstream was also made.
>
> We now have ptests runs for meta-oe but on a subset of recipes and they are
> run regularly as part of testing. So perhaps it will be good to enable
> ptests for
> this and add it to PTESTS_FAST_META_OE in
> meta-oe/conf/include/ptest-packagelists-meta-oe.inc
> currently this recipe is part of PTESTS_PROBLEMS_META_OE which means
> tests are not ready to be enabled, it will be good to sort this out for future.
>

Ptest for libgpiod require a kernel feature (gpio-sim module) to be
enabled if using the yocto kernel. Could this pose a problem? I have
an automated yocto build that runs the ptests locally but it would be
great to have it on official autobuilders too.

> The
> > patch did not go upstream in this form and needs some more work.
> > Please Cc me on future patches to any of the libgpiod recipes.
> >
>
> Thanks for signing up although I am not sure how to make it visible,
> perhaps it would be good to
> add maintainer info in the recipe header in standard way.
>

Will do, thanks.

> > In the meantime. Khem: could you please revert this?
> >
>
> Yes we can.
>

Thank you.

Bartosz

> > Bart
> >
> > > tag.
> > >
> > > Thanks,
> > >
> > > ../Randy
> > >
> > > Signed-off-by: Joe Slater <joe.slater@windriver.com>
> > > ---
> > >  ...-ptest-modify-delays-in-toggle-tests.patch | 60 +++++++++++++++++++
> > >  .../libgpiod/libgpiod_2.0.1.bb                |  2 +
> > >  2 files changed, 62 insertions(+)
> > >  create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> > >
> > > diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> > > new file mode 100644
> > > index 0000000000..11f2d5c4a9
> > > --- /dev/null
> > > +++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
> > > @@ -0,0 +1,60 @@
> > > +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 test
> > > +
> > > +The test "gpioset: toggle (continuous)" uses fixed delays to test
> > > +toggling values.  This is not reliable, so we switch to looking
> > > +for transitions from one value to another.
> > > +
> > > +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.1.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> > > index 337554cd89..91c4d27692 100644
> > > --- a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> > > +++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
> > > @@ -9,6 +9,8 @@ LIC_FILES_CHKSUM = " \
> > >
> > >  FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}-2.x:"
> > >
> > > +SRC_URI += "file://0001-ptest-modify-delays-in-toggle-tests.patch"
> > > +
> > >  SRC_URI[sha256sum] = "b5367d28d045b36007a4ffd42cceda4c358737ef4f2ce22b0c1d05ec57a38392"
> > >
> > >  # Enable all project features for ptest
> > >
> > >
> > > --
> > > # Randy MacLeod
> > > # Wind River Linux
> > >
> > >
> > > -=-=-=-=-=-=-=-=-=-=-=-
> > > Links: You receive all messages sent to this group.
> > > View/Reply Online (#102793): https://lists.openembedded.org/g/openembedded-devel/message/102793
> > > Mute This Topic: https://lists.openembedded.org/mt/99114621/3618139
> > > Group Owner: openembedded-devel+owner@lists.openembedded.org
> > > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [brgl@bgdev.pl]
> > > -=-=-=-=-=-=-=-=-=-=-=-
> > >
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
new file mode 100644
index 0000000000..11f2d5c4a9
--- /dev/null
+++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-ptest-modify-delays-in-toggle-tests.patch
@@ -0,0 +1,60 @@ 
+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 test
+
+The test "gpioset: toggle (continuous)" uses fixed delays to test
+toggling values.  This is not reliable, so we switch to looking
+for transitions from one value to another.
+
+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.1.bb b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
index 337554cd89..91c4d27692 100644
--- a/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
+++ b/meta-oe/recipes-support/libgpiod/libgpiod_2.0.1.bb
@@ -9,6 +9,8 @@  LIC_FILES_CHKSUM = " \
 
 FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}-2.x:"
 
+SRC_URI += "file://0001-ptest-modify-delays-in-toggle-tests.patch"
+
 SRC_URI[sha256sum] = "b5367d28d045b36007a4ffd42cceda4c358737ef4f2ce22b0c1d05ec57a38392"
 
 # Enable all project features for ptest