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

from autotest_lib.client.common_lib import utils

AUTHOR = 'sbasi'
NAME = 'brillo_Gtests'
TIME = 'MEDIUM'
TEST_TYPE = 'Server'

DOC = """
This test runs all the native gTests found on a Brillo DUT.

Usage: --args='whitelist=True'          # Only run whitelisted tests.
       --args='filter="*glob* *test*"'  # Only run tests matching the globs.
       --args='tests="/test /another"'  # Add specific tests to the list.
"""

args_dict = utils.args_to_dict(args)

def run(machine):
    use_whitelist = args_dict.pop('whitelist', None)
    filter_tests = args_dict.pop('filter', '').split()
    native_tests = args_dict.pop('tests', '').split()
    if args_dict:
        raise error.AutoservError('unknown args: %r' % args_dict)
    job.run_test('brillo_Gtests', host=hosts.create_host(machine),
                 use_whitelist=use_whitelist, filter_tests=filter_tests,
                 native_tests=native_tests)


parallel_simple(run, machines)