Shuqian Zhao | d28312f | 2015-05-11 13:56:10 -0700 | [diff] [blame] | 1 | # Copyright 2015 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 | |
| 5 | AUTHOR = "shuqianz, chromeos-infra" |
| 6 | NAME = "suite_attr_wrapper" |
| 7 | |
| 8 | TIME = "SHORT" |
| 9 | TEST_CATEGORY = "General" |
| 10 | TEST_CLASS = "suite" |
| 11 | TEST_TYPE = "Server" |
| 12 | |
| 13 | DOC = """ |
| 14 | This is a wrapper suite to trigger tests that satisfy any attribute boolean |
| 15 | expression. |
| 16 | |
| 17 | @param build: The name of the image to test. |
| 18 | Ex: x86-mario-release/R17-1412.33.0-a1-b29 |
| 19 | @param board: The board to test on. Ex: x86-mario |
| 20 | @param pool: The pool of machines to utilize for scheduling. If pool=None |
| 21 | board is used. |
| 22 | @param check_hosts: require appropriate live hosts to exist in the lab. |
| 23 | @param SKIP_IMAGE: (optional) If present and True, don't re-image devices. |
| 24 | """ |
Allen Li | 3c0d6cb | 2017-08-21 17:05:57 -0700 | [diff] [blame] | 25 | import ast |
Allen Li | e21ed7e | 2017-07-11 11:59:40 -0700 | [diff] [blame] | 26 | import logging |
Shuqian Zhao | d28312f | 2015-05-11 13:56:10 -0700 | [diff] [blame] | 27 | |
| 28 | import common |
| 29 | from autotest_lib.server.cros.dynamic_suite import dynamic_suite |
| 30 | from autotest_lib.server.cros.dynamic_suite import suite |
| 31 | from autotest_lib.server.cros import provision |
| 32 | |
Shuqian Zhao | d28312f | 2015-05-11 13:56:10 -0700 | [diff] [blame] | 33 | # Get the predicate object from attr_filter argument |
Allen Li | 3c0d6cb | 2017-08-21 17:05:57 -0700 | [diff] [blame] | 34 | |
| 35 | # TODO(crbug.com/758427): suite_args needed to support being run by old Autotest |
| 36 | if 'attr_filter' not in args_dict: |
Allen Li | 17bf90d | 2017-09-15 13:00:04 -0700 | [diff] [blame] | 37 | args_dict.update(ast.literal_eval(suite_args)) |
Allen Li | 3c0d6cb | 2017-08-21 17:05:57 -0700 | [diff] [blame] | 38 | |
Shuqian Zhao | d28312f | 2015-05-11 13:56:10 -0700 | [diff] [blame] | 39 | try: |
Allen Li | e21ed7e | 2017-07-11 11:59:40 -0700 | [diff] [blame] | 40 | attr = args_dict['attr_filter'] |
Shuqian Zhao | d28312f | 2015-05-11 13:56:10 -0700 | [diff] [blame] | 41 | attr_predicate = suite.Suite.matches_attribute_expression_predicate(attr) |
| 42 | except KeyError: |
| 43 | logging.error('Unable to find the attribute boolean expression used to ' |
| 44 | 'trigger tests in suite_args %s, please use attr_filter ' |
Allen Li | e21ed7e | 2017-07-11 11:59:40 -0700 | [diff] [blame] | 45 | 'keyword to specify it. suite aborting' % args_dict) |
Shuqian Zhao | d28312f | 2015-05-11 13:56:10 -0700 | [diff] [blame] | 46 | raise |
| 47 | |
Shuqian Zhao | d28312f | 2015-05-11 13:56:10 -0700 | [diff] [blame] | 48 | args_dict['predicate'] = attr_predicate |
| 49 | args_dict.setdefault('name', NAME) |
Shuqian Zhao | 24785cc | 2015-06-01 16:32:18 -0700 | [diff] [blame] | 50 | args_dict['job'] = job |
Shuqian Zhao | d28312f | 2015-05-11 13:56:10 -0700 | [diff] [blame] | 51 | args_dict.setdefault('version_prefix', provision.CROS_VERSION_PREFIX) |
| 52 | |
Shuqian Zhao | 24785cc | 2015-06-01 16:32:18 -0700 | [diff] [blame] | 53 | dynamic_suite.reimage_and_run(**args_dict) |