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