diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-03-27 14:15:35 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-05-01 14:30:27 -0700 |
commit | b01e868a6df433217168ffedecb93b280714d7f7 (patch) | |
tree | 878c162d17c7affc410ccd81ed6eebcbe9207139 /framework | |
parent | cf601813227ca78a5e501a112ab5e5b89ae5c3c2 (diff) |
framework/profile: Add support for meta profiles
MetaProfiles are a single profile composed of more than one profile.
This is designed to allow the old all-inclusive names to continue to
exist without having to keep duplicates of each profile around. A
metaprofile simply declares that it needs profiles a, b, and c and then
runs those.
This allows an "all" meta profile to include opengl, shader, and
glslparser, for example.
A metaprofile is allowed to include XML or python based profiles.
Tested-by: Rafael Antognolli <rafael.antognolli@intel.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/profile.py | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/framework/profile.py b/framework/profile.py index 2395b2250..3975d0606 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -359,6 +359,62 @@ class XMLProfile(object): return iter(self._itertests()) +class MetaProfile(object): + + """Holds multiple profiles but acts like one. + + This is meant to allow classic profiles like all to exist after being + split. + """ + + def __init__(self, filename): + self.forced_test_list = [] + self.filters = [] + self.options = { + 'dmesg': get_dmesg(False), + 'monitor': Monitoring(False), + 'ignore_missing': False, + } + + tree = et.parse(filename) + root = tree.getroot() + self._profiles = [load_test_profile(p.text) + for p in root.findall('.//Profile')] + + for p in self._profiles: + p.options = self.options + + def __len__(self): + if self.forced_test_list or self.filters: + return sum(1 for _ in self.itertests()) + return sum(len(p) for p in self._profiles) + + def setup(self): + pass + + def teardown(self): + pass + + def _itertests(self): + for p in self._profiles: + for k, v in p.itertests(): + if all(f(k, v) for f in self.filters): + yield k, v + + def itertests(self): + if self.forced_test_list: + alltests = dict(self._itertests()) + opts = collections.OrderedDict() + for n in self.forced_test_list: + if self.options['ignore_missing'] and n not in alltests: + opts[n] = DummyTest(n, status.NOTRUN) + else: + opts[n] = alltests[n] + return six.iteritems(opts) + else: + return iter(self._itertests()) + + class TestProfile(object): """Class that holds a list of tests for execution. @@ -456,14 +512,18 @@ def load_test_profile(filename, python=None): XML is tried. """ name = os.path.splitext(os.path.basename(filename))[0] - xml = os.path.join('tests', name + '.xml') if not python: + meta = os.path.join(ROOT_DIR, 'tests', name + '.meta.xml') + if os.path.exists(meta): + return MetaProfile(meta) + xml = os.path.join(ROOT_DIR, 'tests', name + '.xml') if os.path.exists(xml): return XMLProfile(xml) if python is False: - raise exceptions.PiglitFatalError('Cannot open "tests/{}.xml"'.format(name)) + raise exceptions.PiglitFatalError( + 'Cannot open "tests/{0}.xml" or "tests/{0}.meta.xml"'.format(name)) try: mod = importlib.import_module('tests.{0}'.format(name)) |