linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Vincent Fazio <vfazio@xes-inc.com>,
	Kent Gibson <warthog618@gmail.com>,
	 Linus Walleij <linus.walleij@linaro.org>,
	 Erik Schilling <erik.schilling@linaro.org>,
	 Phil Howard <phil@gadgetoid.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	 Koichiro Den <koichiro.den@canonical.com>
Cc: linux-gpio@vger.kernel.org,
	 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH libgpiod] dbus: client: tests: fix the way we wait for simulated chips to appear
Date: Mon, 03 Feb 2025 18:20:27 +0100	[thread overview]
Message-ID: <20250203-fix-dbus-wait-for-chip-v1-1-563f7132c04f@linaro.org> (raw)

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The org.freedesktop.DBus.Peer.Ping() method isn't correct for checking
if a given object is exposed by a service. It only lets us know if the
service is available no matter the object on which it's called (in fact:
it will not return an error even if it's called on a nonexistent object).

While this has worked for most part by accident, if the timing isn't
right, we may start calling methods in chips which are not yet fully
registered. We should try to read the chip's property instead and keep
on waiting for as long as org.freedesktop.DBus.Properties.Get() returns
an error.

While at it: fix the counter increment as its syntax is invalid.

Fixes: a5ab76da1e0a ("dbus: add the D-Bus daemon, command-line client and tests")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 dbus/client/gpiocli-test.bash | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dbus/client/gpiocli-test.bash b/dbus/client/gpiocli-test.bash
index f210183..1d2337d 100755
--- a/dbus/client/gpiocli-test.bash
+++ b/dbus/client/gpiocli-test.bash
@@ -14,11 +14,11 @@ wait_for_sim() {
 
 	while true
 	do
-		gdbus call --system --dest io.gpiod1 \
-			--object-path /io/gpiod1/chips/"$1" \
-			--method org.freedesktop.DBus.Peer.Ping > /dev/null 2>&1 && break
+		gdbus call --system --dest io.gpiod1 --object-path /io/gpiod1/chips/"$1" \
+			--method org.freedesktop.DBus.Properties.Get \
+			io.gpiod1.Chip Label > /dev/null 2>&1 && break
 		sleep 0.01
-		COUNTER=$($COUNTER - 1)
+		COUNTER=$(expr $COUNTER - 1)
 		if [ "$COUNTER" -eq 0 ]
 		then
 			fail "error waiting for the GPIO sim chip to be exported on the bus"

---
base-commit: d6457b28e29a8edadcb619d389878ea99cd4bab4
change-id: 20250203-fix-dbus-wait-for-chip-49e36ad58ee2

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


             reply	other threads:[~2025-02-03 17:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03 17:20 Bartosz Golaszewski [this message]
2025-02-05 13:35 ` [PATCH libgpiod] dbus: client: tests: fix the way we wait for simulated chips to appear Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250203-fix-dbus-wait-for-chip-v1-1-563f7132c04f@linaro.org \
    --to=brgl@bgdev.pl \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=erik.schilling@linaro.org \
    --cc=koichiro.den@canonical.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=phil@gadgetoid.com \
    --cc=vfazio@xes-inc.com \
    --cc=viresh.kumar@linaro.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).