ext_direct_state_access: add test for matrices functions
[piglit.git] / tests / shader.py
blob14f21eef94f556321450615de5845eba10252b5f
1 # coding=utf-8
2 """A profile that runs only ShaderTest instances."""
4 from __future__ import (
5 absolute_import, division, print_function, unicode_literals
7 import collections
8 import os
10 from six.moves import zip
11 import six
13 from framework.options import OPTIONS
14 from framework import grouptools
15 from framework.profile import TestProfile
16 from framework.test.shader_test import ShaderTest, MultiShaderTest
17 from .py_modules.constants import GENERATED_TESTS_DIR, TESTS_DIR
19 __all__ = ['profile']
21 profile = TestProfile()
23 shader_tests = collections.defaultdict(list)
25 # Find and add all shader tests.
26 basepath = os.path.normpath(os.path.join(TESTS_DIR, '..'))
27 gen_basepath = os.path.relpath(os.path.join(GENERATED_TESTS_DIR, '..'), basepath)
29 for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
30 isgenerated = basedir == GENERATED_TESTS_DIR
31 for dirpath, _, filenames in os.walk(basedir):
32 groupname = grouptools.from_path(os.path.relpath(dirpath, basedir))
33 for filename in filenames:
34 testname, ext = os.path.splitext(filename)
35 if ext == '.shader_test':
36 dirname = os.path.relpath(dirpath, basepath)
37 filepath = os.path.join(dirname, filename)
38 if isgenerated:
39 installpath = os.path.relpath(filepath, gen_basepath)
40 else:
41 installpath = None
43 if OPTIONS.process_isolation:
44 test = ShaderTest.new(filepath, installpath)
45 else:
46 shader_tests[groupname].append((filepath, installpath))
47 continue
48 else:
49 continue
51 group = grouptools.join(groupname, testname)
52 assert group not in profile.test_list, group
54 profile.test_list[group] = test
56 # Because we need to handle duplicate group names in TESTS and GENERATED_TESTS
57 # this dictionary is constructed, then added to the actual test dictionary.
58 for group, files in six.iteritems(shader_tests):
59 assert group not in profile.test_list, 'duplicate group: {}'.format(group)
61 # We'll end up with a list of tuples, split that into two lists
62 files, installedfiles = list(zip(*files))
63 files = list(files)
64 installedfiles = list(installedfiles)
66 # If there is only one file in the directory use a normal shader_test.
67 # Otherwise use a MultiShaderTest
68 if len(files) == 1:
69 group = grouptools.join(
70 group, os.path.basename(os.path.splitext(files[0])[0]))
71 profile.test_list[group] = ShaderTest.new(files[0], installedfiles[0])
72 else:
73 if all(i is None for i in installedfiles):
74 installedfiles = None
75 else:
76 for i, n in enumerate(installedfiles):
77 if n is None:
78 installedfiles[i] = files[i]
80 profile.test_list[group] = MultiShaderTest.new(files, installedfiles)