Home | History | Annotate | Download | only in platform_ExternalUsbPeripherals
      1 # Copyright (c) 2018 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.long_cycle"
      9 PURPOSE = "Servo based USB peripheral detection test"
     10 CRITERIA = "This test will fail if any of the actions or checks fail."
     11 TIME = "MEDIUM"
     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 - etc.
     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 
     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")
     52 
     53     action_sequence = str(args_dict.get("action_sequence", default_actions))
     54 
     55     usb_list = ["\"Kingston Technology Company Inc.\"",
     56                 "\"Alcor Micro Corp.\"",
     57                 "\"USB PnP Sound Device: USB Audio|C-Media Electronics, Inc.* Audio\"",
     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 ") :
     63             ["\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\"" ],
     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\"",
     68              "\"USB PnP Sound Device: USB Audio|C-Media USB Headphone Set: USB Audio\""],
     69         # USB stick four partitions volumes
     70         "loggedin:ls -l /media/removable/ | grep -i " :
     71             ["ExFAT", "Ext4", "FAT", "NTFS"],
     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,
     80                  usb_list=usb_list, usb_checks=usb_checks, tag="detect.long_cycle")
     81 
     82 parallel_simple(run, machines)
     83