blob: adef8d3bd4ba6417f640ef69fdc7ebaf14ab8619 [file] [log] [blame]
Matt Nelson56836d42018-11-26 11:49:31 -08001# Copyright (c) 2018 The Chromium OS Authors. All rights reserved.
Helen Zhangc9ce0142016-06-23 13:55:18 -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.long_cycle"
9PURPOSE = "Servo based USB peripheral detection test"
Helen Zhangc9ce0142016-06-23 13:55:18 -070010CRITERIA = "This test will fail if any of the actions or checks fail."
Matt Nelson56836d42018-11-26 11:49:31 -080011TIME = "MEDIUM"
Helen Zhangc9ce0142016-06-23 13:55:18 -070012TEST_CATEGORY = "Functional"
13TEST_CLASS = "platform"
14TEST_TYPE = "server"
15ATTRIBUTES = "suite:usb_detect"
16DEPENDENCIES = "servo, usb_detect"
17
18DOC = """
19This test uses servo to connect/disconnect servo USB hub before and
20after events like reboot, login, suspend, resume etc.
21
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.
Helen Zhangc9ce0142016-06-23 13:55:18 -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("reboot,plug,unplug,"
46 "login,plug,unplug,"
47 "reboot,plug,login,unplug,plug,"
48 "reboot, unplug,login,plug"
49 "suspend,resume,"
50 "unplug,suspend,plug,resume,"
51 "suspend,unplug,resume,plug")
Helen Zhangc9ce0142016-06-23 13:55:18 -070052
53 action_sequence = str(args_dict.get("action_sequence", default_actions))
54
Sridhar Sonti9125c362017-01-12 09:47:58 -080055 usb_list = ["\"Kingston Technology Company Inc.\"",
Helen Zhangc9ce0142016-06-23 13:55:18 -070056 "\"Alcor Micro Corp.\"",
Prasanthi Gangishetty671f8b52018-01-30 15:51:53 -080057 "\"USB PnP Sound Device: USB Audio|C-Media Electronics, Inc.* Audio\"",
Helen Zhangc9ce0142016-06-23 13:55:18 -070058 ]
59 usb_checks = {
60 # USB Audio Output devices
61 str("cras_test_client --dump_server_info | "
62 "awk \"/Output Devices:/,/Output Nodes:/\" | grep -E ") :
Prasanthi Gangishettyd04d0eb2018-01-24 15:30:05 -080063 ["\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\"" ],
Helen Zhangc9ce0142016-06-23 13:55:18 -070064 # USB Audio Input devices
65 str("loggedin:cras_test_client --dump_server_info | "
66 "awk \"/Input Devices:/,/Input Nodes:/\" | grep -E ") :
67 ["\"TeckNet: USB Audio|USB 2.0 PC Camera\"",
Prasanthi Gangishettyd04d0eb2018-01-24 15:30:05 -080068 "\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\""],
Helen Zhangc9ce0142016-06-23 13:55:18 -070069 # USB stick four partitions volumes
70 "loggedin:ls -l /media/removable/ | grep -i " :
Sridhar Sonti3e2e18c2018-06-20 15:40:53 -070071 ["ExFAT", "Ext4", "FAT", "NTFS"],
Helen Zhangc9ce0142016-06-23 13:55:18 -070072 # USB Web camera
73 "cat /sys/class/video4linux/video*/name | grep -E " :
74 ["\"TeckNet|USB 2.0 PC Camera\""],
75 }
76
77 job.run_test("platform_ExternalUsbPeripherals", host=host,
78 disable_sysinfo=True, client_autotest="desktopui_SimpleLogin",
79 action_sequence=action_sequence, repeat=repeat,
Matt Nelson56836d42018-11-26 11:49:31 -080080 usb_list=usb_list, usb_checks=usb_checks, tag="detect.long_cycle")
Helen Zhangc9ce0142016-06-23 13:55:18 -070081
82parallel_simple(run, machines)