# Copyright 2020 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 import utils

AUTHOR = "ChromeOS Team"
NAME = "firmware_ECRestoreFW"
PURPOSE = "Verify the FW restoration capability even from a bad state."
ATTRIBUTES = ""
TIME = "MEDIUM"
TEST_CATEGORY = "Functional"
TEST_CLASS = "firmware"
TEST_TYPE = "server"
JOB_RETRIES = 0
DEPENDENCIES = "ec:cros, servo_state:WORKING"
PY_VERSION = 3

DOC = """
This test flashes a wrong EC RW firmware and checks FW gets restored.

If you want to use a local tarball file to test,
add --args="local_tarball=<path>" to test_that command line.
"""

if 'args_dict' not in locals():
    args_dict = {}

args_dict.update(utils.args_to_dict(args))
servo_args = hosts.CrosHost.get_servo_arguments(args_dict)

def run(machine):
    host = hosts.create_host(machine, servo_args=servo_args)
    job.run_test('firmware_ECRestoreFW', host=host, cmdline_args=args,
                 full_args=args_dict)

parallel_simple(run, machines)
