diff --git a/ofono-end-to-end/osmocom/nitb_test.py b/ofono-end-to-end/osmocom/nitb_test.py index af27b72..641ecdd 100644 --- a/ofono-end-to-end/osmocom/nitb_test.py +++ b/ofono-end-to-end/osmocom/nitb_test.py @@ -47,4 +47,14 @@ class NitbTest(object): # Now register mod.register() - # TODO: Check if all modules are registered? + # TODO: Check if all modems are registered? But this would delay the + # test further. But the modem's SIM card is inside the NITB HLR so it + # should be able to register. + + def teardown(self): + pass + + def run(self): + self.setup() + self.run_test() + self.teardown() diff --git a/ofono-end-to-end/sms_sending_test.py b/ofono-end-to-end/sms_sending_test.py new file mode 100644 index 0000000..aa1274d --- /dev/null +++ b/ofono-end-to-end/sms_sending_test.py @@ -0,0 +1,60 @@ +# 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 . + +# Hi. I am going to send SMS between all available modules and then wait +# for it to complete and verify that all messages arrived and find out +# which one is missing. + +from osmocom.nitb_test import NitbTest + +class SmsMassTest(NitbTest): + def __init__(self, host, sms_to_send=1000): + NitbTest.__init__(self, host) + self.sms_to_send = sms_to_send + + def run_test(self): + """Run the test""" + + self.clear_all_sms() + + extensions = self.ext2mod.keys() + for nr in xrange(1, self.sms_to_send): + for modem in self.avail_modems: + self.send_sms(nr, modem, extensions) + + # Now wait.... TODO. We could connect to the MessageAdded/Removed + # signal and enter the event loop here... + print("Queued a lot of SMS... now waiting") + + def clear_all_sms(self): + # Clear all SMS so we can easily verify we get SMS.. + for modem in self.avail_modems: + sms = modem.sms() + for msg in sms.all_message_names(): + sms.get_message(sms).cancel() + + def send_sms(self, nr, modem, extension_lists): + # Send a SMS to all extensions + sms = modem.sms() + for extension in extension_lists: + # Do not send a SMS to myself (unless this wants to be tested) + if self.ext2mod[extension] == modem: + continue + + text = "This is SMS %d from %s to %s" % (nr, self.mod2ext[modem], extension) + sms.send_message(extension, text, False) + +if __name__ == "__main__": + SmsMassTest('localhost').run()