1# Copyright (c) 2014 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 = "jimishs@google.com"
8NAME = "kernel_ExternalUsbPeripheralsDetectionTest"
9PURPOSE = "Kernel USB detection test"
10CRITERIA = "This test will fail if any of the actions or checks fail."
11TIME = "SHORT"
12TEST_CATEGORY = "Functional"
13TEST_CLASS = "platform, kernel"
14TEST_TYPE = "server"
15ATTRIBUTES = "suite:kernel_usb"
16SUITE = "kernel_usb"
17DEPENDENCIES = "servo, kernel_usb"
18
19DOC = """
20This test uses servo to connect USB devices.
21This test verifies if drivers are created for each USB device or not.
22
23The test fails if
24- if USB device is not detected in lsusb command
25- if driver for USB device is not created
26- USB detected peripherals are different than expected
27- there is no servo board attached
28
29Set1 is set of four USB peripherals plugged
30- LG Android phone
31- USB 3G dongle
32- USB HD Webcam - should be Logitech HD Pro Webcam C920
33- USB3.0 Card Reader
34- USB Headphone
35- USB Mouse
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    usb_checks = {
45        # Microsoft Headphone
46        str("lsusb -v -d 045e:070f") :
47            ["idVendor\s+0x045e\s+Microsoft", "Audio"],
48        # Huawei 3G USB modem/dongle
49        str("lsusb -v -d 12d1:1506") :
50            ["idVendor\s+0x12d1\s+Huawei", "idProduct\s+0x1506\s+Modem"],
51        # LG Android phone (commenting out due to crbug.com/488667)
52        #str("lsusb -v -d 1004:61fa") :
53        #    ["idVendor\s+0x1004\s+LG\s+Elect", "iProduct.*LGE\s+Android"],
54        # Webcam
55        str("lsusb -v -d 058f:") :
56            ["idVendor\s+0x058f\s+Alcor", "iProduct.*(TeckNet|2.0 PC Camera)"],
57        # Mouse
58        str("lsusb -v -d 04f2:0939") :
59            ["idVendor\s+0x04f2\s+Chicony", "iProduct.*Optical\s+Mouse"],
60        # Card Reader
61        str("lsusb -v -d 0bda:0306") :
62            ["idVendor\s+0x0bda\s+Realtek", "iProduct.*USB3.0\s+Card\s+Reader"],
63        }
64
65    vendor_id_dict_control_file = {'045e': 'Microsoft Headphone',
66                                   '12d1': 'Huawei 3G modem/dongle',
67                                   #commenting out due to crbug.com/488667
68                                   #'1004': 'LG Android phone',
69                                   '058f': 'Webcam',
70                                   '04f2': 'Mouse',
71                                   '0bda': 'Card Reader',
72                                  }
73
74    job.run_test("kernel_ExternalUsbPeripheralsDetectionTest", host=host,
75                 disable_sysinfo=True, usb_checks=usb_checks,
76                 vendor_id_dict_control_file=vendor_id_dict_control_file)
77
78parallel_simple(run, machines)
79