[autotest] Allow comma-delineated lists of suites in SUITE tag
dynamic_suite searches through all control files to find SUITE tags that contain the desired
suite name. We used to check for strict equivalence. Now, we support SUITE tags that are
comma-delineated, e.g. 'bvt, kernel-stress'. 'bvt' or 'kernel-stress' will match this,
but 'kernel' will not.
BUG=chromium-os:26794
TEST=unit
TEST=./server/autoserv test_suites/dev_harness
STATUS=Fixed
Change-Id: Id805e32bd456a232d287fca32c6aaf03493c3b8f
Reviewed-on: https://gerrit.chromium.org/gerrit/16496
Commit-Ready: Chris Masone <cmasone@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/server/cros/dynamic_suite.py b/server/cros/dynamic_suite.py
index e0fd6d0..803d350 100644
--- a/server/cros/dynamic_suite.py
+++ b/server/cros/dynamic_suite.py
@@ -246,6 +246,24 @@
@staticmethod
+ def name_in_tag_predicate(name):
+ """Returns predicate that takes a control file and looks for |name|.
+
+ Builds a predicate that takes in a parsed control file (a ControlData)
+ and returns True if the SUITE tag is present and contains |name|.
+
+ @param name: the suite name to base the predicate on.
+ @return a callable that takes a ControlData and looks for |name| in that
+ ControlData object's suite member.
+ """
+ def parse(suite):
+ """Splits a string on ',' optionally surrounded by whitespace."""
+ return map(lambda x: x.strip(), suite.split(','))
+
+ return lambda t: hasattr(t, 'suite') and name in parse(t.suite)
+
+
+ @staticmethod
def create_from_name(name, build, cf_getter=None,
afe=None, tko=None, pool=None):
"""
@@ -268,11 +286,10 @@
"""
if cf_getter is None:
cf_getter = Suite.create_ds_getter(build)
- return Suite(lambda t: hasattr(t, 'suite') and t.suite == name,
+ return Suite(Suite.name_in_tag_predicate(name),
name, build, cf_getter, afe, tko, pool)
-
def __init__(self, predicate, tag, build, cf_getter, afe=None, tko=None,
pool=None):
"""