aboutsummaryrefslogtreecommitdiff
path: root/server/site_tests/platform_ExternalUsbPeripherals/control.detect.unplug_login_plug
blob: 04a74784920a7dd9e7364563720508cc938b87f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from autotest_lib.server import utils

AUTHOR = "Chrome OS Team"
NAME = "platform_ExternalUsbPeripherals.detect.unplug_login_plug"
PURPOSE = "Servo based USB peripherals detection test"
CRITERIA = "This test will fail if any of the actions or checks fail."
TIME = "SHORT"
TEST_CATEGORY = "Functional"
TEST_CLASS = "platform"
TEST_TYPE = "server"
#ATTRIBUTES = "suite:usb_detect"
DEPENDENCIES = "servo_state:WORKING"

DOC = """
This test uses servo to connect/disconnect servo USB hub before and
after events like reboot, login, suspend, resume etc.

The test fails if
- device is pingable when suspended
- wrong action passed through action_sequence flag
- USB detected peripherals are different than expected
- there is no servo board attached
- USB peripherals checks(usb_checks below) on command line fail
Other detection checks can be added for each peripheral

Set of four USB peripherals plugged
- USB headset
- USB HD Webcam - should be Logitech HD Pro Webcam C920
- USB stick with four partitions named ExFAT  Ext4  FAT  NTFS
- USB mouse
- USB 3G modem
- USB SD card reader(one microSD card plugged)
- USB connected phone(optional)
"""

args_dict = utils.args_to_dict(args)
servo_args = hosts.CrosHost.get_servo_arguments(args_dict)

def run(machine):
    host = hosts.create_host(machine, servo_args=servo_args)

    repeat = int(args_dict.get("repeat", 1))

    default_actions = str("unplug,login,plug")

    action_sequence = str(args_dict.get("action_sequence", default_actions))

    usb_list = ["\"Kingston Technology Company Inc.\"",
                "\"Alcor Micro Corp.|GEMBIRD\"",
                "\"USB PnP Sound Device: USB Audio|C-Media Electronics, Inc.* Audio\"",
               ]
    usb_checks = {
        # USB Audio Output devices
        str("cras_test_client --dump_server_info | "
            "awk \"/Output Devices:/,/Output Nodes:/\" | grep -E ") :
            ["\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\"" ],
        # USB Audio Input devices
        str("loggedin:cras_test_client --dump_server_info | "
            "awk \"/Input Devices:/,/Input Nodes:/\" | grep -iE ") :
            ["\"TeckNet: USB Audio|USB ?2.0 PC Camera\"",
             "\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\""],
        # USB stick four partitions volumes
        "loggedin:ls -l /media/removable/ | grep -i " :
            ["ExFAT", "Ext4", "FAT", "NTFS"],
        # USB Web camera
        "cat /sys/class/video4linux/video*/name | grep -iE " :
            ["\"TeckNet|USB ?2.0 PC Camera\""],
        }

    job.run_test("platform_ExternalUsbPeripherals", host=host,
                 disable_sysinfo=True, client_autotest="desktopui_SimpleLogin",
                 action_sequence=action_sequence, repeat=repeat,
                 usb_list=usb_list, usb_checks=usb_checks, tag="detect.unplug_login_plug")

parallel_simple(run, machines)