• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2018 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 = "ChromeOS Team"
8NAME = "platform_ExternalUsbPeripherals.detect.long_cycle"
9PURPOSE = "Servo based USB peripheral detection test"
10CRITERIA = "This test will fail if any of the actions or checks fail."
11TIME = "MEDIUM"
12TEST_CATEGORY = "Functional"
13TEST_CLASS = "platform"
14TEST_TYPE = "server"
15ATTRIBUTES = "suite:usb_detect"
16DEPENDENCIES = "servo_state:WORKING"
17PY_VERSION = 3
18
19DOC = """
20This test uses servo to connect/disconnect servo USB hub before and
21after events like reboot, login, suspend, resume etc.
22
23The 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
29Other detection checks can be added for each peripheral
30
31Set 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- etc.
36"""
37
38args_dict = utils.args_to_dict(args)
39servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
40
41def run(machine):
42    host = hosts.create_host(machine, servo_args=servo_args)
43
44    repeat = int(args_dict.get("repeat", 1))
45
46    default_actions = str("reboot,plug,unplug,"
47                          "login,plug,unplug,"
48                          "reboot,plug,login,unplug,plug,"
49                          "reboot, unplug,login,plug,"
50                          "suspend,resume,"
51                          "unplug,suspend,plug,resume,"
52                          "suspend,unplug,resume,plug")
53
54    action_sequence = str(args_dict.get("action_sequence", default_actions))
55
56    usb_list = ["\"Netac Technology Co., Ltd OnlyDisk\"",
57                "\"Alcor Micro Corp.|GEMBIRD\"",
58                "\"USB PnP Sound Device: USB Audio|C-Media Electronics, Inc.* Audio\"",
59               ]
60    usb_checks = {
61        # USB Audio Output devices
62        str("cras_test_client --dump_server_info | "
63            "awk \"/Output Devices:/,/Output Nodes:/\" | grep -E ") :
64            ["\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\"" ],
65        # USB Audio Input devices
66        str("loggedin:cras_test_client --dump_server_info | "
67            "awk \"/Input Devices:/,/Input Nodes:/\" | grep -iE ") :
68            ["\"TeckNet: USB Audio|USB ?2.0 PC Camera\"",
69             "\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\""],
70        # USB stick four partitions volumes
71        "loggedin:ls -l /media/removable/ | grep -i " :
72            ["ExFAT", "Ext4", "FAT", "NTFS"],
73        # USB Web camera
74        "cat /sys/class/video4linux/video*/name | grep -iE " :
75            ["\"TeckNet|USB ?2.0 PC Camera|Video Capture|Video Output|Metadata\""],
76        }
77
78    job.run_test("platform_ExternalUsbPeripherals", host=host,
79                 disable_sysinfo=True, client_autotest="desktopui_SimpleLogin",
80                 action_sequence=action_sequence, repeat=repeat,
81                 usb_list=usb_list, usb_checks=usb_checks, tag="detect.long_cycle")
82
83parallel_simple(run, machines)
84