Adds a script that exits with success when state changes to "ready"
---
 Makefile.am         |  2 +-
 test/wait-for-ready | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100755 test/wait-for-ready

diff --git a/Makefile.am b/Makefile.am
index a574170..af14dcc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -354,7 +354,7 @@ test_scripts = test/get-state test/list-services \
                test/test-new-supplicant test/service-move-before \
                test/set-global-timeservers test/get-global-timeservers \
                test/set-nameservers test/set-domains test/set-timeservers \
-               test/set-clock
+               test/set-clock test/wait-for-ready
 
 test_scripts += test/vpn-connect test/vpn-disconnect test/vpn-get \
                test/monitor-vpn test/vpn-property
diff --git a/test/wait-for-ready b/test/wait-for-ready
new file mode 100755
index 0000000..797317d
--- /dev/null
+++ b/test/wait-for-ready
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+import gobject
+
+import sys
+import dbus
+import dbus.mainloop.glib
+from functools import partial
+
+bus_name = "net.connman"
+iface = "net.connman.Manager"
+path = "/"
+prop_name = "State"
+
+def check_state(state):
+       return state == 'ready' or state == 'online'
+
+def state_changed(mainloop, name, value):
+       if check_state(value):
+               mainloop.quit();
+
+if __name__ == '__main__':
+       dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+       bus = dbus.SystemBus()
+
+       mainloop = gobject.MainLoop()
+
+       bus.add_signal_receiver(
+               partial(state_changed, mainloop),
+               bus_name=bus_name,
+               dbus_interface=iface,
+               path=path,
+               signal_name="PropertyChanged",
+               arg0=prop_name)
+
+       dev = bus.get_object(bus_name, path)
+       manager = dbus.Interface(dev, iface)
+       props = manager.GetProperties()
+
+       if not check_state(props[prop_name]):
+               mainloop.run()
-- 
2.1.1

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to