Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 1 | # Copyright (c) 2018 The Chromium OS Authors. All rights reserved. |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 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" |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 8 | NAME = "platform_ExternalUsbPeripherals.detect.crash_check_short" |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 9 | PURPOSE = "Servo based USB boot stress test" |
| 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" |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 16 | DEPENDENCIES = "servo, usb_detect" |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 17 | |
| 18 | DOC = """ |
| 19 | This test uses servo to connect/disconnect servo USB hub before and |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 20 | after events like reboot, login, suspend, resume etc. |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 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 |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 34 | - etc |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 35 | """ |
| 36 | |
| 37 | args_dict = utils.args_to_dict(args) |
| 38 | servo_args = hosts.CrosHost.get_servo_arguments(args_dict) |
| 39 | |
| 40 | def run(machine): |
| 41 | host = hosts.create_host(machine, servo_args=servo_args) |
| 42 | |
| 43 | repeat = int(args_dict.get("repeat", 1)) |
| 44 | |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 45 | default_actions = str("plug,unplug,login,plug,unplug," |
| 46 | "suspend,plug,resume,suspend,unplug,resume") |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 47 | |
| 48 | action_sequence = str(args_dict.get("action_sequence", default_actions)) |
| 49 | |
Sridhar Sonti | 9125c36 | 2017-01-12 09:47:58 -0800 | [diff] [blame] | 50 | usb_list = ["\"Kingston Technology Company Inc.\"", |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 51 | "\"Alcor Micro Corp.\"", |
Prasanthi Gangishetty | 671f8b5 | 2018-01-30 15:51:53 -0800 | [diff] [blame] | 52 | "\"USB PnP Sound Device: USB Audio|C-Media Electronics, Inc.* Audio\"", |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 53 | ] |
| 54 | usb_checks = { |
| 55 | # USB Audio Output devices |
| 56 | str("cras_test_client --dump_server_info | " |
| 57 | "awk \"/Output Devices:/,/Output Nodes:/\" | grep -E ") : |
Prasanthi Gangishetty | d04d0eb | 2018-01-24 15:30:05 -0800 | [diff] [blame] | 58 | ["\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\"" ], |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 59 | # USB Audio Input devices |
| 60 | str("loggedin:cras_test_client --dump_server_info | " |
| 61 | "awk \"/Input Devices:/,/Input Nodes:/\" | grep -E ") : |
| 62 | ["\"TeckNet: USB Audio|USB 2.0 PC Camera\"", |
Prasanthi Gangishetty | d04d0eb | 2018-01-24 15:30:05 -0800 | [diff] [blame] | 63 | "\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\""], |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 64 | # USB stick four partitions volumes |
| 65 | "loggedin:ls -l /media/removable/ | grep -i " : |
Sridhar Sonti | 3e2e18c | 2018-06-20 15:40:53 -0700 | [diff] [blame] | 66 | ["ExFAT", "Ext4", "FAT", "NTFS"], |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 67 | # USB Web camera |
| 68 | "cat /sys/class/video4linux/video*/name | grep -E " : |
| 69 | ["\"TeckNet|USB 2.0 PC Camera\""], |
| 70 | } |
| 71 | |
| 72 | job.run_test("platform_ExternalUsbPeripherals", host=host, |
| 73 | disable_sysinfo=True, client_autotest="desktopui_SimpleLogin", |
| 74 | action_sequence=action_sequence, repeat=repeat, |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 75 | usb_list=usb_list, usb_checks=usb_checks, tag="detect.crash_check_short") |
Sridhar Sonti | b91faa5 | 2016-06-30 15:19:11 -0700 | [diff] [blame] | 76 | |
| 77 | parallel_simple(run, machines) |