# Copyright (c) 2010 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 = "Chrome OS Team"
NAME = "firmware_ShellBall"
TIME = "SHORT"
TEST_CATEGORY = "Functional"
TEST_CLASS = "firmware"
TEST_TYPE = "server"

DOC = """
chromeos-firmwareupdate functional testing.

This script first copies shellball to DUT and runs all functional tests.

Syntax:
   ./test_that --board=<BOARD> <IP> -a "xml_config=<xml_config_file>
   shellball_path=<shellball_directory> shellball_name=<shellball_name>
   servo_serial=<serial number>" firmware_ShellBall/control
"""
from autotest_lib.client.common_lib import error

# Convert autoserv args to something usable.
opts = dict([[k, v] for (k, _, v) in [x.partition('=') for x in args]])

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

def run_shellball(machine):
    # Verify bios path arg.
    if 'shellball_path' and 'shellball_name' not in opts:
        raise error.TestFail('Invalid shellball information.')
    # Setup the client machine.
    host = hosts.create_host(machine, servo_args=servo_args)
    job.run_test("firmware_ShellBall", host=host,
                 cmdline_args=args,
                 shellball_path=opts['shellball_path'],
                 shellball_name=opts['shellball_name'],
                 disable_sysinfo=True)

parallel_simple(run_shellball, machines)