1# Copyright (c) 2014 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.server import utils 6 7AUTHOR = "Harpreet Grewal <harpreet@chromium.org>" 8NAME = "cellular_StaleModemReboot" 9PURPOSE = "Verify modem is available for testing." 10CRITERIA = """ 11This test will fail if either there is no response to modem status command or 12modem is in a non testable state after two or more tries. 13""" 14TIME = "SHORT" 15TEST_CATEGORY = "Functional" 16TEST_CLASS = "network" 17TEST_TYPE = "server" 18ATTRIBUTES = "suite:cellular_modem_repair" 19DEPENDENCIES = "servo" 20 21DOC = """ 22 Tests that a cellular modem is available for testing. 23 24 The test attempts to detect the modem state by running the modem status 25 command on the DUT and strips the state from its output. The test saves the 26 original modem state and reboots the DUT regardless of what state the modem 27 is in. After the reboot, it tries to get the modem state again and if the 28 modem does not respond or the state is one of the following as listed below, 29 it tries to reboot the DUT for a maximum of two tries by default. User can 30 override the number of tries by passing a tries flag with a desired value. 31 32 REBOOT STATES (If modem is in any of these states, DUT is cold rebooted using 33 the servo.): 34 MODEM STATE FAILED = -1 35 MODEM STATE UNKNOWN = 0 36 MODEM STATE DISABLED = 3 37 MODEM STATE DISABLING = 4 38 MODEM STATE DISCONNECTING = 9 39 GOBI MODEM STATE UNKNOWN = 0 40 GOBI MODEM STATE DISABLED = 10 41 GOBI MODEM STATE DISABLING = 20 42 GOBI MODEM STATE DISCONNECTING = 70 43 44 WAIT DELAY STATES (Waits for a maximum of 120 seconds for the modem to get 45 into a testable state. If the modem is still not in a stable state after the 46 first try, DUT will be rebooted.): 47 MODEM STATE INITIALIZING = 1 48 MODEM STATE ENABLING = 5 49 MODEM STATE ENABLED = 6 50 MODEM STATE SEARCHING = 7 51 GOBI MODEM STATE ENABLING = 30 52 GOBI MODEM STATE ENABLED = 40 53 GOBI MODEM STATE SEARCHING = 50 54 55 STABLE STATES (Test does nothing.): 56 MODEM STATE REGISTERED = 8 57 MODEM STATE CONNECTING = 10 58 MODEM STATE CONNECTED = 11 59 GOBI MODEM STATE REGISTERED = 60 60 GOBI MODEM STATE CONNECTING = 80 61 GOBI MODEM STATE CONNECTED = 90 62 63 LOCKED STATE (Test fails, the device should never be in this state unless 64 the SIM is locked): 65 MODEM STATE LOCKED = 2 66 67""" 68 69args_dict = utils.args_to_dict(args) 70servo_args = hosts.CrosHost.get_servo_arguments(args_dict) 71 72def run_StaleModemReboot(machine): 73 host = hosts.create_host(machine, servo_args=servo_args) 74 tries = int(args_dict.get('tries', 2)) 75 job.run_test('cellular_StaleModemReboot', host=host, tries=tries) 76 77parallel_simple(run_StaleModemReboot, machines) 78