1# Copyright (c) 2013 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 5from autotest_lib.client.bin import test, utils 6from autotest_lib.client.common_lib import error 7from autotest_lib.client.cros import backchannel, network 8 9from autotest_lib.client.cros.cellular import cellular, cell_tools, environment 10 11import contextlib, logging, re, socket, string, time, urllib2 12 13from autotest_lib.client.cros import flimflam_test_path 14import flimflam, routing 15 16# Cellular smoke test and documentation for writing cell tests 17 18class cellular_Smoke(test.test): 19 version = 1 20 21 # The autotest infrastructure calls run_once. The control file 22 # fetches the JSON lab config and passes it in as a python object 23 24 def run_once(self, config, technology): 25 # The DefaultCellularTestContext builds: 26 # * a backchannel ethernet context. This makes a virtual 27 # device that connects the DUT to the test infrastructure. 28 # It has restrictive routes and is outside of flimflam's 29 # control. This makes the tests resilient to flimflam 30 # restarts and helps to ensure that the test is actually 31 # sending traffic on the cellular link 32 # * an OtherDeviceShutdownContext, which shuts down other 33 # network devices on the host. Again, this is to ensure 34 # that test traffic goes over the modem 35 # * A cellular test environment context, which lets us 36 # interact with the cell network. 37 38 with environment.DefaultCellularTestContext(config) as c: 39 env = c.env 40 flim = flimflam.FlimFlam() 41 env.StartDefault(technology) 42 network.ResetAllModems(flim) 43 cell_tools.PrepareModemForTechnology('', technology) 44 45 # TODO(rochberg) Need to figure out what isn't settling here. 46 # Going to wait 'til after ResetAllModems changes land. 47 time.sleep(10) 48 49 # Clear all errors before we start. 50 # Resetting the modem above may have caused some errors on the 51 # 8960 (eg. lost connection, etc). 52 env.emulator.ClearErrors() 53 54 service = env.CheckedConnectToCellular() 55 env.CheckHttpConnectivity() 56 env.CheckedDisconnectFromCellular(service) 57