Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: client/site_tests/network_LockedSIM/network_LockedSIM.py

Issue 5988012: autotest: Add network_LockedSIM test. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Fixes. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/site_tests/network_LockedSIM/control ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from autotest_lib.client.bin import test
6 from autotest_lib.client.common_lib import error
7
8 import os, time
9 import dbus, dbus.mainloop.glib, gobject
10 import random
11
12 class TestFailure(Exception):
Jason Glasgow 2011/04/06 20:27:36 rom autotest_lib.client.common_lib import error T
Elly Fong-Jones 2011/04/07 14:05:03 Done.
13 pass
14
15 class network_LockedSIM(test.test):
16 version = 1
17
18 def modem(self, path):
19 return self.bus.get_object('org.freedesktop.ModemManager', path)
20
21 def EnableModem(self, path):
22 print 'EnableModem: %s' % path
23 self.modem(path).Enable(True, dbus_interface=self.imodem)
24
25 def ChangePin(self, path, old, new):
26 self.modem(path).ChangePin(old, new, dbus_interface=self.icard)
27
28 def EnablePin(self, path, pin):
29 self.modem(path).EnablePin(pin, True, dbus_interface=self.icard)
30
31 def DisablePin(self, path, pin):
32 self.modem(path).EnablePin(pin, False, dbus_interface=self.icard)
33
34 def Reset(self, path):
35 self.modem(path).Reset(dbus_interface=self.imodem)
36
37 def Unlock(self, path, pin):
38 self.modem(path).SendPin(pin, dbus_interface=self.icard)
39
40 def retries(self, path):
41 iface = 'org.freedesktop.DBus.Properties'
42 return self.modem(path).Get(self.imodem, 'UnlockRetries',
43 dbus_interface=iface)
Jason Glasgow 2011/04/06 20:27:36 self.iface, and delete line above.
Elly Fong-Jones 2011/04/07 14:05:03 Done.
44
45 def run_once(self, mmpath='/org/freedesktop/ModemManager'):
Jason Glasgow 2011/04/06 20:27:36 You should probably import mm It provides mm.Enum
Elly Fong-Jones 2011/04/07 14:05:03 Done.
46 self.imm = 'org.freedesktop.ModemManager'
47 self.imodem = 'org.freedesktop.ModemManager.Modem'
48 self.icard = 'org.freedesktop.ModemManager.Modem.Gsm.Card'
49 failed = []
50 self.bus = dbus.SystemBus()
51 self.mm = self.bus.get_object('org.freedesktop.ModemManager', mmpath)
52
53 self.devs = self.mm.EnumerateDevices(dbus_interface=self.imm)
54 print 'devs: %d' % len(self.devs)
55 for d in self.devs:
56 print 'device: %s' % d
57 # Make sure we can change the pin - this guarantees that the pin is
58 # properly set to start with.
59 try:
60 self.Unlock(d, '1111')
61 except dbus.exceptions.DBusException:
62 # We get this back if the sim's already unlocked.
63 pass
64 self.EnableModem(d)
65 self.ChangePin(d, '1111', '1112')
66 self.ChangePin(d, '1112', '1111')
67 try:
68 self.DisablePin(d, '1111')
69 except dbus.exceptions.DBusException:
70 # We get this back if the pin's already disabled.
71 pass
72 self.EnablePin(d, '1111')
73 self.Reset(d)
74
75 # Give the modem a little while to come back...
76 time.sleep(20)
77
78 # Re-enumerate devices, since we're hoping they all disappeared and
79 # reappeared.
80 self.devs = self.mm.EnumerateDevices(dbus_interface=self.imm)
81 print 'newdevs: %d' % len(self.devs)
82 for d in self.devs:
83 print 'newdevice: %s' % d
84 # Send a command to the modem, then wait a second. It seems to take
85 # the Ericsson F3307 (at least) from initial access to usefulness,
86 # so we make a dummy retries() call, wait a second, then get the
87 # real retry count.
88 self.retries(d)
89 time.sleep(1)
90 retries = self.retries(d)
91 print 'real retries: %u' % retries
92 if retries < 2:
93 print 'retries too low (%d), bailing' % retries
94 failed.append(d)
95 continue
96 try:
97 self.Unlock(d, '1112')
98 except dbus.exceptions.DBusException:
99 pass
100 # We expect a failure here, so swallow the DBus exception.
101 nretries = self.retries(d)
102 self.Unlock(d, '1111')
103 self.EnableModem(d)
104 self.DisablePin(d, '1111')
105 print '%s retries %d nretries %d' % (d, retries, nretries)
106 if nretries != (retries - 1):
107 # We can't just raise the exception here - if there are multiple
108 # modems in the system, we might raise on the first one and
109 # leave the others locked.
110 failed.append(d)
111
112 if failed:
113 raise TestFailure("%s" % failed)
Jason Glasgow 2011/04/06 20:27:36 raise error.TestFail('Failed for devices: %s' % ',
Elly Fong-Jones 2011/04/07 14:05:03 Done.
OLDNEW
« no previous file with comments | « client/site_tests/network_LockedSIM/control ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698