# Copyright 2015 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.

import logging

from autotest_lib.client.common_lib import utils


AUTHOR = "kathrelkeld"
NAME = "stress_ClientTestReboot"
TIME = "SHORT"
TEST_CATEGORY = "Functional"
TEST_CLASS = "Stress"
TEST_TYPE = "server"

DOC = """
This test takes the name of a client side test.  This test is run many times
over, rebooting the DUT in between each time.

Example usage:
test_that stress_ClientTestReboot <ip> --board=<board>
                                       --args="testname=NAME loops=N"
"""

args_dict = utils.args_to_dict(args)

def run_reboot_stress(machine):
    if 'testname' in args_dict and 'loops' in args_dict:
        testname = args_dict.get('testname')
        loops = int(args_dict.get('loops'))
        job.run_test('stress_ClientTestReboot', client_ip=machine,
                     testname=testname, loops=loops)
    else:
        logging.info('Please provide the name of a client autotest and the '
                     'number of times the test should be run. '
                     '"testname=<test> loops=<number>"')

parallel_simple(run_reboot_stress, machines)