1# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5AUTHOR = "akeshet, chromeos-lab-infrastructure"
6NAME = "test_that_wrapper"
7PURPOSE = "Wrapper for ad-hoc suites kicked of by test_that tool."
8CRITERIA = "All tests must pass."
9
10TIME = "SHORT"
11TEST_CATEGORY = "General"
12TEST_CLASS = "suite"
13TEST_TYPE = "Server"
14
15DOC = """
16This is a wrapper suite for lab jobs that get kicked off by developers
17running the test_that tool on their desks, but targetting devices in the lab.
18
19@param build: The name of the image to test.
20              Ex: x86-mario-release/R17-1412.33.0-a1-b29
21@param board: The board to test on. Ex: x86-mario
22@param pool: The pool of machines to utilize for scheduling. If pool=None
23             board is used.
24@param check_hosts: require appropriate live hosts to exist in the lab.
25@param SKIP_IMAGE: (optional) If present and True, don't re-image devices.
26"""
27
28import logging, shlex
29
30import common
31from autotest_lib.server.cros.dynamic_suite import dynamic_suite
32from autotest_lib.site_utils import test_runner_utils
33from autotest_lib.site_utils import test_that
34from autotest_lib.server.cros import provision
35
36# Values specified in this bug template will override default values when
37# filing bugs on tests that are a part of this suite. If left unspecified
38# the bug filer will fallback to it's defaults.
39_BUG_TEMPLATE = {
40    'labels': ['test_that_wrapper'],
41    'owner': '',
42    'status': None,
43    'summary': None,
44    'title': None,
45    'ccs': ['beeps@chromium.org']
46}
47
48
49try:
50   arguments = test_that.parse_arguments(shlex.split(suite_args))
51except SystemExit:
52    logging.error('Unable to parse test_that arguments %s, suite aborting',
53                  shlex.split(suite_args))
54    raise
55
56parsed_test_arguments = [test_runner_utils.get_predicate_for_test_arg(test_arg)
57                         for test_arg in arguments.tests]
58sub_predicates, descriptions = zip(*parsed_test_arguments)
59
60logging.info('This is a test_that triggered suite, consisting of:')
61for desc in descriptions:
62    logging.info('A %s.', desc)
63
64combined_predicate = lambda test: any(f(test) for f in sub_predicates)
65
66args_dict['name'] = NAME
67args_dict['max_runtime_mins'] = 20
68args_dict['predicate'] = combined_predicate
69args_dict['job'] = job
70args_dict['add_experimental'] = True
71args_dict['version_prefix'] = provision.CROS_VERSION_PREFIX
72args_dict['bug_template'] = _BUG_TEMPLATE
73
74dynamic_suite.reimage_and_run(**args_dict)
75