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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/site_tests/network_LockedSIM/control ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/site_tests/network_LockedSIM/network_LockedSIM.py
diff --git a/client/site_tests/network_LockedSIM/network_LockedSIM.py b/client/site_tests/network_LockedSIM/network_LockedSIM.py
new file mode 100644
index 0000000000000000000000000000000000000000..a2f599964e207df1b660256c5babab88c5329761
--- /dev/null
+++ b/client/site_tests/network_LockedSIM/network_LockedSIM.py
@@ -0,0 +1,113 @@
+# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from autotest_lib.client.bin import test
+from autotest_lib.client.common_lib import error
+
+import os, time
+import dbus, dbus.mainloop.glib, gobject
+import random
+
+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.
+ pass
+
+class network_LockedSIM(test.test):
+ version = 1
+
+ def modem(self, path):
+ return self.bus.get_object('org.freedesktop.ModemManager', path)
+
+ def EnableModem(self, path):
+ print 'EnableModem: %s' % path
+ self.modem(path).Enable(True, dbus_interface=self.imodem)
+
+ def ChangePin(self, path, old, new):
+ self.modem(path).ChangePin(old, new, dbus_interface=self.icard)
+
+ def EnablePin(self, path, pin):
+ self.modem(path).EnablePin(pin, True, dbus_interface=self.icard)
+
+ def DisablePin(self, path, pin):
+ self.modem(path).EnablePin(pin, False, dbus_interface=self.icard)
+
+ def Reset(self, path):
+ self.modem(path).Reset(dbus_interface=self.imodem)
+
+ def Unlock(self, path, pin):
+ self.modem(path).SendPin(pin, dbus_interface=self.icard)
+
+ def retries(self, path):
+ iface = 'org.freedesktop.DBus.Properties'
+ return self.modem(path).Get(self.imodem, 'UnlockRetries',
+ 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.
+
+ 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.
+ self.imm = 'org.freedesktop.ModemManager'
+ self.imodem = 'org.freedesktop.ModemManager.Modem'
+ self.icard = 'org.freedesktop.ModemManager.Modem.Gsm.Card'
+ failed = []
+ self.bus = dbus.SystemBus()
+ self.mm = self.bus.get_object('org.freedesktop.ModemManager', mmpath)
+
+ self.devs = self.mm.EnumerateDevices(dbus_interface=self.imm)
+ print 'devs: %d' % len(self.devs)
+ for d in self.devs:
+ print 'device: %s' % d
+ # Make sure we can change the pin - this guarantees that the pin is
+ # properly set to start with.
+ try:
+ self.Unlock(d, '1111')
+ except dbus.exceptions.DBusException:
+ # We get this back if the sim's already unlocked.
+ pass
+ self.EnableModem(d)
+ self.ChangePin(d, '1111', '1112')
+ self.ChangePin(d, '1112', '1111')
+ try:
+ self.DisablePin(d, '1111')
+ except dbus.exceptions.DBusException:
+ # We get this back if the pin's already disabled.
+ pass
+ self.EnablePin(d, '1111')
+ self.Reset(d)
+
+ # Give the modem a little while to come back...
+ time.sleep(20)
+
+ # Re-enumerate devices, since we're hoping they all disappeared and
+ # reappeared.
+ self.devs = self.mm.EnumerateDevices(dbus_interface=self.imm)
+ print 'newdevs: %d' % len(self.devs)
+ for d in self.devs:
+ print 'newdevice: %s' % d
+ # Send a command to the modem, then wait a second. It seems to take
+ # the Ericsson F3307 (at least) from initial access to usefulness,
+ # so we make a dummy retries() call, wait a second, then get the
+ # real retry count.
+ self.retries(d)
+ time.sleep(1)
+ retries = self.retries(d)
+ print 'real retries: %u' % retries
+ if retries < 2:
+ print 'retries too low (%d), bailing' % retries
+ failed.append(d)
+ continue
+ try:
+ self.Unlock(d, '1112')
+ except dbus.exceptions.DBusException:
+ pass
+ # We expect a failure here, so swallow the DBus exception.
+ nretries = self.retries(d)
+ self.Unlock(d, '1111')
+ self.EnableModem(d)
+ self.DisablePin(d, '1111')
+ print '%s retries %d nretries %d' % (d, retries, nretries)
+ if nretries != (retries - 1):
+ # We can't just raise the exception here - if there are multiple
+ # modems in the system, we might raise on the first one and
+ # leave the others locked.
+ failed.append(d)
+
+ if failed:
+ 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.
« 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