mirror of git://git.sysmocom.de/ofono
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.
This commit is contained in:
parent
d9f252fb61
commit
62c34467a2
|
@ -5,36 +5,53 @@ import dbus
|
||||||
|
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
|
|
||||||
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
|
manager = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')
|
||||||
'org.ofono.Manager')
|
|
||||||
|
|
||||||
modems = manager.GetModems()
|
if (len(sys.argv) == 3):
|
||||||
|
modem = sys.argv[1]
|
||||||
for path, properties in modems:
|
context_idx = int(sys.argv[2]) - 1
|
||||||
if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
|
else:
|
||||||
continue
|
modem = None
|
||||||
|
modems = manager.GetModems()
|
||||||
connman = dbus.Interface(bus.get_object('org.ofono', path),
|
for path, properties in modems:
|
||||||
'org.ofono.ConnectionManager')
|
if "org.ofono.ConnectionManager" in properties["Interfaces"]:
|
||||||
|
modem = path
|
||||||
contexts = connman.GetContexts()
|
break
|
||||||
|
if (modem is None):
|
||||||
if (len(contexts) == 0):
|
|
||||||
print("No context available")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
connman.SetProperty("Powered", dbus.Boolean(1))
|
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
|
||||||
path = contexts[int(sys.argv[1])][0]
|
|
||||||
else:
|
|
||||||
path = contexts[0][0]
|
|
||||||
|
|
||||||
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)
|
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)
|
||||||
|
|
||||||
|
modemapi = dbus.Interface(bus.get_object('org.ofono', modem), 'org.ofono.Modem')
|
||||||
|
properties = modemapi.GetProperties()
|
||||||
|
|
||||||
|
if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
|
||||||
|
print("org.ofono.ConnectionManager not found")
|
||||||
|
exit(2)
|
||||||
|
|
||||||
|
connman = dbus.Interface(bus.get_object('org.ofono', modem),
|
||||||
|
'org.ofono.ConnectionManager')
|
||||||
|
|
||||||
|
contexts = connman.GetContexts()
|
||||||
|
|
||||||
|
if (len(contexts) == 0):
|
||||||
|
print("No context available")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
connman.SetProperty("Powered", dbus.Boolean(1))
|
||||||
|
|
||||||
|
path = contexts[context_idx][0]
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
|
@ -5,34 +5,51 @@ import dbus
|
||||||
|
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
|
|
||||||
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
|
manager = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')
|
||||||
'org.ofono.Manager')
|
|
||||||
|
|
||||||
modems = manager.GetModems()
|
if (len(sys.argv) == 3):
|
||||||
|
modem = sys.argv[1]
|
||||||
for path, properties in modems:
|
context_idx = int(sys.argv[2]) - 1
|
||||||
if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
|
else:
|
||||||
continue
|
modem = None
|
||||||
|
modems = manager.GetModems()
|
||||||
connman = dbus.Interface(bus.get_object('org.ofono', path),
|
for path, properties in modems:
|
||||||
'org.ofono.ConnectionManager')
|
if "org.ofono.ConnectionManager" in properties["Interfaces"]:
|
||||||
|
modem = path
|
||||||
contexts = connman.GetContexts()
|
break
|
||||||
|
if (modem is None):
|
||||||
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]
|
|
||||||
|
|
||||||
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)
|
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)
|
||||||
|
|
||||||
|
modemapi = dbus.Interface(bus.get_object('org.ofono', modem), 'org.ofono.Modem')
|
||||||
|
properties = modemapi.GetProperties()
|
||||||
|
|
||||||
|
if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
|
||||||
|
print("org.ofono.ConnectionManager not found")
|
||||||
|
exit(2)
|
||||||
|
|
||||||
|
connman = dbus.Interface(bus.get_object('org.ofono', modem),
|
||||||
|
'org.ofono.ConnectionManager')
|
||||||
|
|
||||||
|
contexts = connman.GetContexts()
|
||||||
|
|
||||||
|
if (len(contexts) == 0):
|
||||||
|
print("No context available")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
path = contexts[context_idx][0]
|
||||||
|
|
||||||
|
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 deactivating %s: %s" % (path, str(e)))
|
||||||
|
exit(2)
|
||||||
|
|
Loading…
Reference in New Issue