~ubuntu-branches/ubuntu/wily/ofono/wily-proposed

« back to all changes in this revision

Viewing changes to test/rilmodem/sim/test-sim-removal

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Tony Espy, Vicamo Yang, Alfonso Sanchez-Beato
  • Date: 2015-02-04 09:18:00 UTC
  • mfrom: (1.3.30)
  • Revision ID: package-import@ubuntu.com-20150204091800-ptp0cyfidrf69ar1
Tags: 1.12.bzr6886+15.04.20150204-0ubuntu1
[ Tony Espy ]
* test/rilmodem/sim: add new SIM test scripts
* test: fix test-call-forwarding script (LP: #1396323)

[ Vicamo Yang ]
* mtkmodem, rilmodem: re-factor naming
  This change makes the naming of GRil, mtk_data,
  ofono_modem, and ril_data instances consistent.
* rilmodem: fix duplicate APPSTATE* constants
* gril: get rid of duplicate ringbuffer.h (LP: #1408250)
* mtk.c: use RIL_RADIO_POWER request for single slot modems

[ Alfonso Sanchez-Beato ]
* gril, unit, mtk.c: SIM mode and session ID fixes for arale
  For MTK modems, DUAL_SIM_MODE requests aren't necessary.  Also
  add session-id to SIM IO requests for newer MTK modems.
* rilmodem, mtk.c, ril.c: add auto-answer support
  This change adds auto-answer support which is triggered
  by usage of a special test SIM (MCC/MNC 001/01 or 001/001).
* mtkmodem, unit, mtk.c: support arale firmware switch
  This change will cause the correct modem firmware to
  be loaded based upon the SIM MCC and MNC.  If new
  firmware is loaded, a modem reset is triggered.
* mtkmodem, unit, mtk.c: handle suspend events
  RIL_RESUME_REGISTRATION requests are not sent to
  MTK modems if suspend events are received.
* gril, include, mbpi, rilmodem, mtkmodem, rilmodem,
  gprs, unit, modem, ril.c, mtk.c: LTE updates
  This changes detection logic for LTE modems to rilmodem
  ( via an environment var ) and mtkmodem ( via a modem
  query ).  If detected, a RIL_INITIAL_ATTACH_APN request
  is not sent to the modem during gprs initialization.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
#
 
3
#  oFono - Open Source Telephony - RIL Modem test
 
4
#
 
5
#  Copyright (C) 2014 Canonical Ltd.
 
6
#
 
7
#  This program is free software; you can redistribute it and/or modify
 
8
#  it under the terms of the GNU General Public License version 2 as
 
9
#  published by the Free Software Foundation.
 
10
#
 
11
#  This program is distributed in the hope that it will be useful,
 
12
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
#  GNU General Public License for more details.
 
15
#
 
16
#  You should have received a copy of the GNU General Public License
 
17
#  along with this program; if not, write to the Free Software
 
18
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
#
 
20
# This test ensures that basic modem information is available
 
21
# when the modem is online and has a valid, unlocked SIM present.
 
22
 
 
23
"""Tests SIM removal detection/notification
 
24
 
 
25
This module contains a functional test which checks a running
 
26
ofono/rilmodem/mtkmodem instance to ensure that the correct
 
27
DBus signals are generated and the correct properties updated
 
28
when a SIM is removed from a running device.  The script by
 
29
default will wait for 60 seconds for the SIM to be removed after
 
30
which it will exit.
 
31
 
 
32
NOTE - this test by default verifies the removal of a SIM from
 
33
a single modem.  If the device is multi-SIM, the first modem
 
34
will be used by default.  The -m argument can be used to specify
 
35
the second modem if needed.
 
36
 
 
37
SETUP:
 
38
 
 
39
 * Run this script
 
40
 
 
41
 * Remove the SIM card
 
42
 
 
43
Options:
 
44
 
 
45
 * -t / --timer - specify a timeout after which the script
 
46
    will exit.
 
47
 
 
48
ToDo:
 
49
 * If run on the emulator, make this script use console
 
50
   commands to configure the modem(s) for the required
 
51
   conditions ( ie. no SIM(s), online )
 
52
"""
 
53
 
 
54
import dbus.mainloop.glib
 
55
import simtestutil
 
56
 
 
57
from gi.repository import GLib
 
58
from simtestutil import *
 
59
 
 
60
def parse_args():
 
61
 
 
62
        parser = argparse.ArgumentParser()
 
63
 
 
64
        parser.add_argument("-t",
 
65
                        "--timeout",
 
66
                        dest="timeout",
 
67
                        help="""Specify a timeout which causes
 
68
                        the script to exit""",
 
69
                        default=60,
 
70
                        )
 
71
 
 
72
        return simtestutil.parse_args(parser)
 
73
 
 
74
class TestSimRemovalNotification(SimTestCase):
 
75
 
 
76
        def modem_listener(self, name, value, path=None):
 
77
                if self.args.debug:
 
78
                        print("Modem property: '%s' changed to '%s'"
 
79
                                % (name, str(value)))
 
80
 
 
81
                if name == "Interfaces":
 
82
                        if "org.ofono.SimManager" in value:
 
83
                                if (self.check_no_sim_present(path) != True):
 
84
                                        self.sim_present_failure = True
 
85
 
 
86
                                self.mainloop.quit()
 
87
 
 
88
        def sim_listener(self, name, value):
 
89
                if self.args.debug:
 
90
                        print("SIM property: '%s' changed to '%s'"
 
91
                                % (name, str(value)))
 
92
 
 
93
                if name == "Present":
 
94
                        if value != 0:
 
95
                                self.sim_present_signal_failure = True
 
96
 
 
97
                        self.mainloop.quit()
 
98
 
 
99
        def setUp(self):
 
100
                self.args = args
 
101
                self.product = get_product()
 
102
 
 
103
                self.sim_present_failure = False
 
104
                self.sim_present_signal_failure = False
 
105
                self.timeout_failure = False
 
106
 
 
107
                self.mainloop = GLib.MainLoop()
 
108
 
 
109
                dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
110
 
 
111
                SimTestCase.setUp(self)
 
112
 
 
113
                interval_ms = 1000 * int(self.args.timeout)
 
114
                GLib.timeout_add(interval_ms, self.timeout_cb)
 
115
 
 
116
        def timeout_cb(self):
 
117
                if self.args.debug:
 
118
                        print("ALL DONE - timer fired!!!")
 
119
 
 
120
                self.timeout_failure = True
 
121
                self.mainloop.quit()
 
122
 
 
123
        def validate_modem(self, path):
 
124
                modem = self.validate_modem_properties(path, True, True)
 
125
 
 
126
                if self.if_supports_sim_offline() == True:
 
127
 
 
128
                        # valid SimManager properties
 
129
                        simmanager = self.get_simmanager(path)
 
130
 
 
131
                        simmanager.connect_to_signal("PropertyChanged",
 
132
                                                 self.sim_listener)
 
133
                else:
 
134
                        modem.connect_to_signal("PropertyChanged",
 
135
                                                 self.modem_listener,
 
136
                                                path_keyword="path")
 
137
 
 
138
        def test_main(self):            
 
139
                if args.debug:
 
140
                        print ("ro.build.product: %s" % self.product)
 
141
 
 
142
                if len(args.modem) > 0:
 
143
                        self.validate_modem(args.modem)
 
144
                else:
 
145
                        self.validate_modem(self.modems[0][0])
 
146
 
 
147
                self.mainloop.run()
 
148
 
 
149
                self.assertFalse(self.timeout_failure)
 
150
                self.assertFalse(self.sim_present_failure)
 
151
                self.assertFalse(self.sim_present_signal_failure)
 
152
 
 
153
if __name__ == "__main__":
 
154
        args = parse_args()
 
155
 
 
156
        sim_unittest_main(args)