1# Copyright 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. 4from autotest_lib.client.common_lib.cros.cfm.usb import usb_device_spec 5from autotest_lib.server.cros.cfm.configurable_test.dsl import * 6from autotest_lib.server import utils 7 8AUTHOR = "kerl@google.com, chromeos-meetings@google.com" 9NAME = "enterprise_CFM_PeripheralQualification.power_cycle" 10PURPOSE = "Stresses a peripheral device by repeatedly power cycling its USB port." 11CRITERIA = ("The device detectable as a USB device after each cycle " 12 "and no crash files appear") 13TIME = "MEDIUM" 14TEST_CATEGORY = "Stress" 15TEST_TYPE = "server" 16 17DOC = """ 18Repeatedly power cycle the connected device and verify it appears 19as a USB device after each cycle. Verifies that no new crash files 20appear. 21 22The test requires a vid_pid argument (e.g. 18d1:8001) that determines which 23device to power cycle. This enables testing custom devices from Moblab or from 24a local workstation. 25 26In Moblab, add vid_pid=<vid:pid> under Advanced Options -> Args. 27 28Locally, add arguments with --args when running test_that. Example: 29test_that --autotest_dir ~/trunk/src/third_party/autotest/files/ \ 30 --board=guado --args 'servo_host= vid_pid=18d1:8001' \ 31 chromeos6-row22-rack13-host7 enterprise_CFM_PeripheralQualification.power_cycle 32""" 33 34args_dict = utils.args_to_dict(args) 35vid,pid = args_dict['vid_pid'].split(':') 36# The product is only informational, set it to whatever. 37product = args_dict.get('product', 'customProduct') 38# Interfaces are only needed when verifying them, set them to empty in this case. 39interfaces = [] 40device = usb_device_spec.UsbDeviceSpec(vid, pid, product, interfaces) 41repeat = int(args_dict.get('repeat', 10)) 42 43cfm_test = CfmTest( 44 configuration=Configuration(skip_enrollment=True), 45 scenario=Scenario( 46 AssertUsbDevices([device]), 47 RepeatTimes(repeat, Scenario( 48 PowerCycleUsbPort([device]), 49 AssertNoNewCrashes() 50 )) 51 ), 52) 53 54def run_test(machine): 55 job.run_test("enterprise_CFM_PeripheralQualification", 56 cfm_test = cfm_test, 57 tag = 'power_cycle', 58 host = hosts.create_host(machine)) 59 60parallel_simple(run_test, machines) 61