summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>2014-06-10 10:27:17 +0200
committerDenis Kenzior <denkenz@gmail.com>2014-06-10 23:36:09 -0500
commit62c34467a287a6aa8790cf11b6a7c628e358d398 (patch)
tree51a013c75b8a6df12d246c6edba7aef20f571d2a /test
parentd9f252fb61f1f84b150a2cd74db4a5052380f867 (diff)
downloadofono-62c34467a287a6aa8790cf11b6a7c628e358d398.tar.bz2
test: Adapt data test scripts to multi-modem
Some tests scripts were not ready to handle situations with more than one modem present. This change fixes the data context scripts.
Diffstat (limited to 'test')
-rwxr-xr-xtest/activate-context65
-rwxr-xr-xtest/deactivate-context63
2 files changed, 81 insertions, 47 deletions
diff --git a/test/activate-context b/test/activate-context
index 22ad1734..e4fc7027 100755
--- a/test/activate-context
+++ b/test/activate-context
@@ -5,36 +5,53 @@ import dbus
bus = dbus.SystemBus()
-manager = dbus.Interface(bus.get_object('org.ofono', '/'),
- 'org.ofono.Manager')
+manager = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')
+
+if (len(sys.argv) == 3):
+ modem = sys.argv[1]
+ context_idx = int(sys.argv[2]) - 1
+else:
+ modem = None
+ modems = manager.GetModems()
+ for path, properties in modems:
+ if "org.ofono.ConnectionManager" in properties["Interfaces"]:
+ modem = path
+ break
+ if (modem is None):
+ exit(2)
+ if (len(sys.argv) == 1):
+ context_idx = 0
+ elif (len(sys.argv) == 2):
+ context_idx = int(sys.argv[1]) - 1
+ else:
+ print("Usage: %s [modem] [context_number]" % (sys.argv[0]))
+ exit(1)
-modems = manager.GetModems()
+modemapi = dbus.Interface(bus.get_object('org.ofono', modem), 'org.ofono.Modem')
+properties = modemapi.GetProperties()
-for path, properties in modems:
- if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
- continue
+if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
+ print("org.ofono.ConnectionManager not found")
+ exit(2)
- connman = dbus.Interface(bus.get_object('org.ofono', path),
- 'org.ofono.ConnectionManager')
+connman = dbus.Interface(bus.get_object('org.ofono', modem),
+ 'org.ofono.ConnectionManager')
- contexts = connman.GetContexts()
+contexts = connman.GetContexts()
- if (len(contexts) == 0):
- print("No context available")
- sys.exit(1)
+if (len(contexts) == 0):
+ print("No context available")
+ exit(1)
- connman.SetProperty("Powered", dbus.Boolean(1))
+connman.SetProperty("Powered", dbus.Boolean(1))
- if len(sys.argv) > 1:
- path = contexts[int(sys.argv[1])][0]
- else:
- path = contexts[0][0]
+path = contexts[context_idx][0]
- context = dbus.Interface(bus.get_object('org.ofono', path),
- 'org.ofono.ConnectionContext')
+context = dbus.Interface(bus.get_object('org.ofono', path),
+ 'org.ofono.ConnectionContext')
- try:
- context.SetProperty("Active", dbus.Boolean(1), timeout = 100)
- except dbus.DBusException as e:
- print("Error activating %s: %s" % (path, str(e)))
- exit(2)
+try:
+ context.SetProperty("Active", dbus.Boolean(1), timeout = 100)
+except dbus.DBusException as e:
+ print("Error activating %s: %s" % (path, str(e)))
+ exit(2)
diff --git a/test/deactivate-context b/test/deactivate-context
index bc2ffd31..5c86a713 100755
--- a/test/deactivate-context
+++ b/test/deactivate-context
@@ -5,34 +5,51 @@ import dbus
bus = dbus.SystemBus()
-manager = dbus.Interface(bus.get_object('org.ofono', '/'),
- 'org.ofono.Manager')
+manager = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')
+
+if (len(sys.argv) == 3):
+ modem = sys.argv[1]
+ context_idx = int(sys.argv[2]) - 1
+else:
+ modem = None
+ modems = manager.GetModems()
+ for path, properties in modems:
+ if "org.ofono.ConnectionManager" in properties["Interfaces"]:
+ modem = path
+ break
+ if (modem is None):
+ exit(2)
+ if (len(sys.argv) == 1):
+ context_idx = 0
+ elif (len(sys.argv) == 2):
+ context_idx = int(sys.argv[1]) - 1
+ else:
+ print("Usage: %s [modem] [context_number]" % (sys.argv[0]))
+ exit(1)
-modems = manager.GetModems()
+modemapi = dbus.Interface(bus.get_object('org.ofono', modem), 'org.ofono.Modem')
+properties = modemapi.GetProperties()
-for path, properties in modems:
- if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
- continue
+if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
+ print("org.ofono.ConnectionManager not found")
+ exit(2)
- connman = dbus.Interface(bus.get_object('org.ofono', path),
- 'org.ofono.ConnectionManager')
+connman = dbus.Interface(bus.get_object('org.ofono', modem),
+ 'org.ofono.ConnectionManager')
- contexts = connman.GetContexts()
+contexts = connman.GetContexts()
- if (len(contexts) == 0):
- print("No context available")
- sys.exit(1)
+if (len(contexts) == 0):
+ print("No context available")
+ sys.exit(1)
- if len(sys.argv) > 1:
- path = contexts[int(sys.argv[1])][0]
- else:
- path = contexts[0][0]
+path = contexts[context_idx][0]
- context = dbus.Interface(bus.get_object('org.ofono', path),
- 'org.ofono.ConnectionContext')
+context = dbus.Interface(bus.get_object('org.ofono', path),
+ 'org.ofono.ConnectionContext')
- try:
- context.SetProperty("Active", dbus.Boolean(0))
- except dbus.DBusException as e:
- print("Error activating %s: %s" % (path, str(e)))
- exit(2)
+try:
+ context.SetProperty("Active", dbus.Boolean(0))
+except dbus.DBusException as e:
+ print("Error deactivating %s: %s" % (path, str(e)))
+ exit(2)