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

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: Typo 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..08cc964500ff27aa3889d4a4a0ee541e972d41c1
--- /dev/null
+++ b/client/site_tests/network_LockedSIM/network_LockedSIM.py
@@ -0,0 +1,116 @@
+# 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
+
+from autotest_lib.client.cros import flimflam_test_path
+import mm
+
+class TestFailure(Exception):
+ pass
+
+class network_LockedSIM(test.test):
+ version = 1
+
+ def modem(self, mm):
+ return self.bus.get_object(mm[0].service, mm[1])
+
+ def EnableModem(self, mm):
+ self.modem(mm).Enable(True, dbus_interface=self.imodem)
+
+ def ChangePin(self, mm, old, new):
+ self.modem(mm).ChangePin(old, new, dbus_interface=self.icard)
+
+ def EnablePin(self, mm, pin):
+ self.modem(mm).EnablePin(pin, True, dbus_interface=self.icard)
+
+ def DisablePin(self, mm, pin):
+ self.modem(mm).EnablePin(pin, False, dbus_interface=self.icard)
+
+ def Reset(self, mm):
+ self.modem(mm).Reset(dbus_interface=self.imodem)
+
+ def Unlock(self, mm, pin):
+ self.modem(mm).SendPin(pin, dbus_interface=self.icard)
+
+ def retries(self, mm):
+ return self.modem(mm).Get(self.imodem, 'UnlockRetries',
+ dbus_interface=self.iprops)
+
+ def run_once(self):
+ global mm
+ self.iprops = 'org.freedesktop.DBus.Properties'
+ 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.devs = mm.EnumerateDevices()
+ print 'devs: %d' % len(self.devs)
+ for modem in self.devs:
+ print 'device: %s' % modem[1]
+ # Make sure we can change the pin - this guarantees that the pin is
+ # properly set to start with.
+ try:
+ self.Unlock(modem, '1111')
+ except dbus.exceptions.DBusException:
+ # We get this back if the sim's already unlocked.
+ pass
+ self.EnableModem(modem)
+ self.ChangePin(modem, '1111', '1112')
+ self.ChangePin(modem, '1112', '1111')
+ try:
+ self.DisablePin(modem, '1111')
+ except dbus.exceptions.DBusException:
+ # We get this back if the pin's already disabled.
+ pass
+ self.EnablePin(modem, '1111')
+ self.Reset(modem)
+
+ # 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 = mm.EnumerateDevices()
+ print 'newdevs: %d' % len(self.devs)
+ for modem in self.devs:
+ print 'newdevice: %s' % modem[1]
+ # 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(modem)
+ time.sleep(1)
+ retries = self.retries(modem)
+ print 'real retries: %u' % retries
+ if retries < 2:
+ print 'retries too low (%d), bailing' % retries
+ failed.append(modem)
+ continue
+ try:
+ self.Unlock(modem, '1112')
+ except dbus.exceptions.DBusException:
+ pass
+ # We expect a failure here, so swallow the DBus exception.
+ nretries = self.retries(modem)
+ self.Unlock(modem, '1111')
+ self.EnableModem(modem)
+ self.DisablePin(modem, '1111')
+ print '%s retries %d nretries %d' % (modem, 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(modem)
+
+ if failed:
+ raise error.TestFail("Failed for devices: %s" % ', '.join(
+ map(lambda x: x[1], failed)))
« 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