# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from autotest_lib.server.cros.cfm.configurable_test.dsl import *
from autotest_lib.server import utils

AUTHOR = "kerl@google.com, chromeos-meetings@google.com"
NAME = "enterprise_CFM_LowLevelPeripheralTest.reboot_stress"
PURPOSE = "Stresses peripheral devices by repeatedly rebooting the DUT."
CRITERIA = ("Atrus,Mimo, and Huddly detectable as USB devices after reboot "
            "and no crash files appear")
ATTRIBUTES = "suite:hotrod"
TIME = "MEDIUM"
TEST_CATEGORY = "Stress"
TEST_TYPE = "server"
DEPENDENCIES="atrus,mimo,huddly"

DOC = """
Repeatedly reboots the DUT and verifies that the Atrus device can be enumerated
after each reboot.
"""

cfm_test = CfmTest(
    configuration=Configuration(skip_enrollment=True),
    scenario=Scenario(
        AssertUsbDevices([ATRUS]),
        AssertUsbDevices(ALL_MIMO_DISPLAYS),
        AssertUsbDevices([HUDDLY_GO]),
        RepeatTimes(10, Scenario(
            RebootDut(),
            AssertUsbDevices([ATRUS]),
            AssertUsbDevices(ALL_MIMO_DISPLAYS),
            AssertUsbDevices([HUDDLY_GO]),
            # TODO(crbug.com/814775): mosys-info always crashes on reboot, why
            # we always have new crash files. Enable this check when that is
            # fixed.
            # AssertNoNewCrashes()
        ))
    ),
)

def run_test(machine):
    job.run_test("enterprise_CFM_LowLevelPeripheralTest",
                 cfm_test = cfm_test,
                 tag = 'reboot_stress',
                 host = hosts.create_host(machine))

parallel_simple(run_test, machines)