blob: 1393864f484763b454f73f580a21dad43e322944 [file] [log] [blame]
Matt Nelson56836d42018-11-26 11:49:31 -08001# Copyright (c) 2018 The Chromium OS Authors. All rights reserved.
Sridhar Sontib91faa52016-06-30 15:19:11 -07002# 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 = "Chrome OS Team"
Matt Nelson56836d42018-11-26 11:49:31 -08008NAME = "platform_ExternalUsbPeripherals.detect.crash_check_short"
Sridhar Sontib91faa52016-06-30 15:19:11 -07009PURPOSE = "Servo based USB boot stress test"
10CRITERIA = "This test will fail if any of the actions or checks fail."
11TIME = "SHORT"
12TEST_CATEGORY = "Functional"
13TEST_CLASS = "platform"
14TEST_TYPE = "server"
15ATTRIBUTES = "suite:usb_detect"
Matt Nelson56836d42018-11-26 11:49:31 -080016DEPENDENCIES = "servo, usb_detect"
Sridhar Sontib91faa52016-06-30 15:19:11 -070017
18DOC = """
19This test uses servo to connect/disconnect servo USB hub before and
Matt Nelson56836d42018-11-26 11:49:31 -080020after events like reboot, login, suspend, resume etc.
Sridhar Sontib91faa52016-06-30 15:19:11 -070021
22The 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
28Other detection checks can be added for each peripheral
29
30Set 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
Matt Nelson56836d42018-11-26 11:49:31 -080034- etc
Sridhar Sontib91faa52016-06-30 15:19:11 -070035"""
36
37args_dict = utils.args_to_dict(args)
38servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
39
40def run(machine):
41 host = hosts.create_host(machine, servo_args=servo_args)
42
43 repeat = int(args_dict.get("repeat", 1))
44
Matt Nelson56836d42018-11-26 11:49:31 -080045 default_actions = str("plug,unplug,login,plug,unplug,"
46 "suspend,plug,resume,suspend,unplug,resume")
Sridhar Sontib91faa52016-06-30 15:19:11 -070047
48 action_sequence = str(args_dict.get("action_sequence", default_actions))
49
Sridhar Sonti9125c362017-01-12 09:47:58 -080050 usb_list = ["\"Kingston Technology Company Inc.\"",
Sridhar Sontib91faa52016-06-30 15:19:11 -070051 "\"Alcor Micro Corp.\"",
Prasanthi Gangishetty671f8b52018-01-30 15:51:53 -080052 "\"USB PnP Sound Device: USB Audio|C-Media Electronics, Inc.* Audio\"",
Sridhar Sontib91faa52016-06-30 15:19:11 -070053 ]
54 usb_checks = {
55 # USB Audio Output devices
56 str("cras_test_client --dump_server_info | "
57 "awk \"/Output Devices:/,/Output Nodes:/\" | grep -E ") :
Prasanthi Gangishettyd04d0eb2018-01-24 15:30:05 -080058 ["\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\"" ],
Sridhar Sontib91faa52016-06-30 15:19:11 -070059 # USB Audio Input devices
60 str("loggedin:cras_test_client --dump_server_info | "
61 "awk \"/Input Devices:/,/Input Nodes:/\" | grep -E ") :
62 ["\"TeckNet: USB Audio|USB 2.0 PC Camera\"",
Prasanthi Gangishettyd04d0eb2018-01-24 15:30:05 -080063 "\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\""],
Sridhar Sontib91faa52016-06-30 15:19:11 -070064 # USB stick four partitions volumes
65 "loggedin:ls -l /media/removable/ | grep -i " :
Sridhar Sonti3e2e18c2018-06-20 15:40:53 -070066 ["ExFAT", "Ext4", "FAT", "NTFS"],
Sridhar Sontib91faa52016-06-30 15:19:11 -070067 # USB Web camera
68 "cat /sys/class/video4linux/video*/name | grep -E " :
69 ["\"TeckNet|USB 2.0 PC Camera\""],
70 }
71
72 job.run_test("platform_ExternalUsbPeripherals", host=host,
73 disable_sysinfo=True, client_autotest="desktopui_SimpleLogin",
74 action_sequence=action_sequence, repeat=repeat,
Matt Nelson56836d42018-11-26 11:49:31 -080075 usb_list=usb_list, usb_checks=usb_checks, tag="detect.crash_check_short")
Sridhar Sontib91faa52016-06-30 15:19:11 -070076
77parallel_simple(run, machines)