From 08888d57cbaff7fc692911a960e40ba46c2281ec Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 8 Apr 2024 19:48:50 +0200 Subject: [PATCH] tests: check for supported dBus interface Instead of blindly relying on sleeping, that dBus understands our dBus interface, query the info with dbus-send. --- test/lib/aux.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/lib/aux.sh b/test/lib/aux.sh index 3d820a1d9..b734a6e74 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -322,12 +322,23 @@ prepare_lvmdbusd() { "$daemon" $lvmdbusdebug > debug.log_LVMDBUSD_out 2>&1 & local pid=$! - sleep 1 echo -n "## checking lvmdbusd IS running..." + for i in {50..0}; do + dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames > dbus_services + grep -q com.redhat.lvmdbus1 dbus_services && break + sleep .1 + done + + if [ "$i" -eq 0 ] ; then + printf "\nFailed to serve lvm dBus service in 5 seconds.\n" + sed -e "s,^,## DBUS_SERVICES: ," dbus_services + return 1 + fi + comm= # TODO: Is there a better check than wait 1 second and check pid? if ! comm=$(ps -p $pid -o comm=) >/dev/null || [[ $comm != lvmdbusd ]]; then - echo "Failed to start lvmdbusd daemon" + printf "\nFailed to start lvmdbusd daemon\n" return 1 fi echo "$pid" > LOCAL_LVMDBUSD -- 2.43.5