1 # Copyright 2016 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.server import utils 6 7 AUTHOR = "Chrome OS Team" 8 NAME = "platform_ExternalUsbPeripherals.detect.login_closelid_openlid" 9 PURPOSE = "Servo based USB boot stress test" 10 CRITERIA = "This test will fail if any of the actions or checks fail." 11 TIME = "SHORT" 12 TEST_CATEGORY = "Functional" 13 TEST_CLASS = "platform" 14 TEST_TYPE = "server" 15 ATTRIBUTES = "suite:usb_detect" 16 DEPENDENCIES = "servo, usb_detect, use_lid" 17 JOB_RETRIES = 2 18 19 DOC = """ 20 This test uses servo to connect/disconnect servo USB hub before and 21 after events like reboot, login, closelid, openlid etc. 22 23 The test fails if 24 - device is pingable when suspended 25 - wrong action passed through action_sequence flag 26 - USB detected peripherals are different than expected 27 - there is no servo board attached 28 - USB peripherals checks(usb_checks below) on command line fail 29 Other detection checks can be added for each peripheral 30 31 Set of four USB peripherals plugged 32 - USB headset 33 - USB HD Webcam - should be Logitech HD Pro Webcam C920 34 - USB stick with four partitions named ExFAT Ext4 FAT NTFS 35 - USB mouse 36 - USB 3G modem 37 - USB SD card reader(one microSD card plugged) 38 - USB connected phone(optional) 39 """ 40 41 args_dict = utils.args_to_dict(args) 42 servo_args = hosts.CrosHost.get_servo_arguments(args_dict) 43 44 def run(machine): 45 host = hosts.create_host(machine, servo_args=servo_args) 46 47 repeat = int(args_dict.get("repeat", 1)) 48 49 default_actions = str("login,closelid,openlid") 50 51 action_sequence = str(args_dict.get("action_sequence", default_actions)) 52 53 usb_list = ["\"Kingston Technology Company Inc.\"", 54 "\"Alcor Micro Corp.\"", 55 "\"Microsoft Corp.|C-Media Electronics, Inc. Audio Adapter\"", 56 ] 57 usb_checks = { 58 # USB Audio Output devices 59 str("cras_test_client --dump_server_info | " 60 "awk \"/Output Devices:/,/Output Nodes:/\" | grep -E ") : 61 ["\"Microsoft LifeChat LX-3000: USB Audio|C-Media USB Headphone Set: USB Audio\"" ], 62 # USB Audio Input devices 63 str("loggedin:cras_test_client --dump_server_info | " 64 "awk \"/Input Devices:/,/Input Nodes:/\" | grep -E ") : 65 ["\"TeckNet: USB Audio|USB 2.0 PC Camera\"", 66 "\"Microsoft LifeChat LX-3000: USB Audio|C-Media USB Headphone Set: USB Audio\""], 67 # USB stick four partitions volumes 68 "loggedin:ls -l /media/removable/ | grep -i " : 69 ["\"SD Card\"", "ExFAT", "Ext4", "FAT", "NTFS"], 70 # USB Web camera 71 "cat /sys/class/video4linux/video*/name | grep -E " : 72 ["\"TeckNet|USB 2.0 PC Camera\""], 73 } 74 75 job.run_test("platform_ExternalUsbPeripherals", host=host, 76 disable_sysinfo=True, client_autotest="desktopui_SimpleLogin", 77 action_sequence=action_sequence, repeat=repeat, 78 usb_list=usb_list, usb_checks=usb_checks, tag="detect.login_closelid_openlid") 79 80 parallel_simple(run, machines) 81