Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 1 | # Copyright 2016 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 | |
| 5 | from autotest_lib.server import utils |
| 6 | |
| 7 | AUTHOR = "Chrome OS Team" |
| 8 | NAME = "platform_ExternalUsbPeripherals.detect.login_unplug_suspend_plug_resume" |
Helen Zhang | bf48c09 | 2016-07-19 10:36:20 -0700 | [diff] [blame] | 9 | PURPOSE = "Servo based USB peripherals detection test" |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 10 | CRITERIA = "This test will fail if any of the actions or checks fail." |
| 11 | TIME = "SHORT" |
| 12 | TEST_CATEGORY = "Functional" |
| 13 | TEST_CLASS = "platform" |
| 14 | TEST_TYPE = "server" |
| 15 | ATTRIBUTES = "suite:usb_detect" |
| 16 | DEPENDENCIES = "servo, usb_detect" |
| 17 | |
| 18 | DOC = """ |
| 19 | This test uses servo to connect/disconnect servo USB hub before and |
| 20 | after events like reboot, login, suspend, resume etc. |
| 21 | |
| 22 | The 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 |
| 28 | Other detection checks can be added for each peripheral |
| 29 | |
| 30 | Set 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 |
| 34 | - USB mouse |
| 35 | - USB 3G modem |
| 36 | - USB SD card reader(one microSD card plugged) |
| 37 | - USB connected phone(optional) |
| 38 | """ |
| 39 | |
| 40 | args_dict = utils.args_to_dict(args) |
| 41 | servo_args = hosts.CrosHost.get_servo_arguments(args_dict) |
| 42 | |
| 43 | def run(machine): |
| 44 | host = hosts.create_host(machine, servo_args=servo_args) |
| 45 | |
| 46 | repeat = int(args_dict.get("repeat", 1)) |
| 47 | |
| 48 | default_actions = str("login,unplug,suspend,plug,resume") |
| 49 | |
| 50 | action_sequence = str(args_dict.get("action_sequence", default_actions)) |
| 51 | |
Sridhar Sonti | 9125c36 | 2017-01-12 09:47:58 -0800 | [diff] [blame] | 52 | usb_list = ["\"Kingston Technology Company Inc.\"", |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 53 | "\"Alcor Micro Corp.\"", |
Prasanthi Gangishetty | 671f8b5 | 2018-01-30 15:51:53 -0800 | [diff] [blame] | 54 | "\"USB PnP Sound Device: USB Audio|C-Media Electronics, Inc.* Audio\"", |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 55 | ] |
| 56 | usb_checks = { |
| 57 | # USB Audio Output devices |
| 58 | str("cras_test_client --dump_server_info | " |
| 59 | "awk \"/Output Devices:/,/Output Nodes:/\" | grep -E ") : |
Prasanthi Gangishetty | d04d0eb | 2018-01-24 15:30:05 -0800 | [diff] [blame] | 60 | ["\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\"" ], |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 61 | # USB Audio Input devices |
| 62 | str("loggedin:cras_test_client --dump_server_info | " |
| 63 | "awk \"/Input Devices:/,/Input Nodes:/\" | grep -E ") : |
| 64 | ["\"TeckNet: USB Audio|USB 2.0 PC Camera\"", |
Prasanthi Gangishetty | d04d0eb | 2018-01-24 15:30:05 -0800 | [diff] [blame] | 65 | "\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\""], |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 66 | # USB stick four partitions volumes |
| 67 | "loggedin:ls -l /media/removable/ | grep -i " : |
Sridhar Sonti | 3e2e18c | 2018-06-20 15:40:53 -0700 | [diff] [blame^] | 68 | ["ExFAT", "Ext4", "FAT", "NTFS"], |
Prasanthi Gangishetty | aa807e2 | 2018-03-30 11:35:57 -0700 | [diff] [blame] | 69 | # Skipping camera checks |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 70 | # USB Web camera |
| 71 | "cat /sys/class/video4linux/video*/name | grep -E " : |
| 72 | ["\"TeckNet|USB 2.0 PC Camera\""], |
Prasanthi Gangishetty | aa807e2 | 2018-03-30 11:35:57 -0700 | [diff] [blame] | 73 | #"eval /usr/local/autotest/tests/camera_V4L2/media_v4l2_test --device=/dev/video$" |
| 74 | #"(ls /dev/video* | tail -n1 | cut -b11) | grep -E " : |
| 75 | # ["\"TestResolutions pass\""], |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 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, |
Helen Zhang | bf48c09 | 2016-07-19 10:36:20 -0700 | [diff] [blame] | 81 | usb_list=usb_list, usb_checks=usb_checks, |
| 82 | tag="detect.login_unplug_suspend_plug_resume") |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 83 | |
| 84 | parallel_simple(run, machines) |