Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 1 | # Copyright (c) 2018 The Chromium OS Authors. All rights reserved. |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -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.long_cycle" |
| 9 | PURPOSE = "Servo based USB peripheral 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." |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 11 | TIME = "MEDIUM" |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 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 |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 34 | - etc. |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -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("reboot,plug,unplug," |
| 46 | "login,plug,unplug," |
| 47 | "reboot,plug,login,unplug,plug," |
| 48 | "reboot, unplug,login,plug" |
| 49 | "suspend,resume," |
| 50 | "unplug,suspend,plug,resume," |
| 51 | "suspend,unplug,resume,plug") |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 52 | |
| 53 | action_sequence = str(args_dict.get("action_sequence", default_actions)) |
| 54 | |
Sridhar Sonti | 9125c36 | 2017-01-12 09:47:58 -0800 | [diff] [blame] | 55 | usb_list = ["\"Kingston Technology Company Inc.\"", |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 56 | "\"Alcor Micro Corp.\"", |
Prasanthi Gangishetty | 671f8b5 | 2018-01-30 15:51:53 -0800 | [diff] [blame] | 57 | "\"USB PnP Sound Device: USB Audio|C-Media Electronics, Inc.* Audio\"", |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 58 | ] |
| 59 | usb_checks = { |
| 60 | # USB Audio Output devices |
| 61 | str("cras_test_client --dump_server_info | " |
| 62 | "awk \"/Output Devices:/,/Output Nodes:/\" | grep -E ") : |
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\"" ], |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 64 | # USB Audio Input devices |
| 65 | str("loggedin:cras_test_client --dump_server_info | " |
| 66 | "awk \"/Input Devices:/,/Input Nodes:/\" | grep -E ") : |
| 67 | ["\"TeckNet: USB Audio|USB 2.0 PC Camera\"", |
Prasanthi Gangishetty | d04d0eb | 2018-01-24 15:30:05 -0800 | [diff] [blame] | 68 | "\"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] | 69 | # USB stick four partitions volumes |
| 70 | "loggedin:ls -l /media/removable/ | grep -i " : |
Sridhar Sonti | 3e2e18c | 2018-06-20 15:40:53 -0700 | [diff] [blame] | 71 | ["ExFAT", "Ext4", "FAT", "NTFS"], |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 72 | # USB Web camera |
| 73 | "cat /sys/class/video4linux/video*/name | grep -E " : |
| 74 | ["\"TeckNet|USB 2.0 PC Camera\""], |
| 75 | } |
| 76 | |
| 77 | job.run_test("platform_ExternalUsbPeripherals", host=host, |
| 78 | disable_sysinfo=True, client_autotest="desktopui_SimpleLogin", |
| 79 | action_sequence=action_sequence, repeat=repeat, |
Matt Nelson | 56836d4 | 2018-11-26 11:49:31 -0800 | [diff] [blame^] | 80 | usb_list=usb_list, usb_checks=usb_checks, tag="detect.long_cycle") |
Helen Zhang | c9ce014 | 2016-06-23 13:55:18 -0700 | [diff] [blame] | 81 | |
| 82 | parallel_simple(run, machines) |