end-to-end: Finally begin with some ofono based End-to-End tests
This is not much of a framework yet but it hopefully turns into one over time. Begin with some helpers for using ofono.
This commit is contained in:
parent
d3cf0e8530
commit
5552afde47
|
@ -1 +1,2 @@
|
|||
*.sw?
|
||||
*.py?
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
End to End tests for OpenBSC/sysmoBTS
|
|
@ -0,0 +1,53 @@
|
|||
# Copyright (C) 2012 Holger Hans Peter Freyther
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import dbus
|
||||
|
||||
def get(bus, name):
|
||||
"""
|
||||
Find the modem
|
||||
"""
|
||||
return dbus.Interface(bus.get_object('org.ofono', name), 'org.ofono.Modem')
|
||||
|
||||
def getmodems(bus):
|
||||
"""
|
||||
Find modems...
|
||||
"""
|
||||
obj = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')
|
||||
return obj.GetModems()
|
||||
|
||||
def enable(modem):
|
||||
"""
|
||||
Enable the given modem on the Bus
|
||||
"""
|
||||
modem.SetProperty("Powered", dbus.Boolean(1), timeout = 120)
|
||||
|
||||
def disable(modem):
|
||||
"""
|
||||
Enable the given modem on the Bus
|
||||
"""
|
||||
modem.SetProperty("Powered", dbus.Boolean(0), timeout = 120)
|
||||
|
||||
def online(modem):
|
||||
"""
|
||||
Switch-on on the RF Modem
|
||||
"""
|
||||
modem.SetProperty("Online", dbus.Boolean(1), timeout = 120)
|
||||
|
||||
def offline(modem):
|
||||
"""
|
||||
Switch-off on the RF Modem
|
||||
"""
|
||||
modem.SetProperty("Online", dbus.Boolean(0), timeout = 120)
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright (C) 2012 Holger Hans Peter Freyther
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import dbus
|
||||
|
||||
def get(bus, path):
|
||||
"""Get the SIM manager"""
|
||||
return dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SimManager')
|
||||
|
||||
def present(sim):
|
||||
return bool(sim.GetProperties(timeout=120)['Present'])
|
||||
|
||||
def imsi(sim):
|
||||
return str(sim.GetProperties(timeout=120)['SubscriberIdentity'])
|
|
@ -0,0 +1,25 @@
|
|||
# Copyright (C) 2012 Holger Hans Peter Freyther
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import dbus
|
||||
|
||||
def get(bus, name):
|
||||
return dbus.Interface(
|
||||
bus.get_object('org.ofono', name),
|
||||
'org.ofono.MessageManager')
|
||||
|
||||
def send_message(manager, number, text, delivery_report):
|
||||
manager.SetProperty('UseDeliveryReports', dbus.Boolean(int(delivery_report)))
|
||||
return manager.SendMessage(number, text)
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright (C) 2012 Holger Hans Peter Freyther
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import dbus
|
||||
import dbus.mainloop.glib
|
||||
|
||||
from osmocom import modem, sms, sim
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
mods = modem.getmodems(bus)
|
||||
mod = modem.get(bus, "/phonesim")
|
||||
modem.enable(mod)
|
||||
modem.online(mod)
|
||||
|
||||
sm = sms.get(bus, "/phonesim")
|
||||
for i in range(1, 10):
|
||||
print sms.send_message(sm, '+491234', 'TEST %d' % i, False)
|
||||
|
||||
s = sim.get(bus, "/phonesim")
|
||||
print sim.present(s)
|
||||
print sim.imsi(s)
|
Reference in New Issue