add new indexing test with dynamic indexing of integer vector
[piglit.git] / framework / test / oclconform.py
blob0a644995dd4de0290b88cbfafab4380e81325618
1 # Copyright 2016 Intel Corporation
2 # Copyright 2014 Advanced Micro Devices, Inc.
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the "Software"),
6 # to deal in the Software without restriction, including without limitation
7 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 # and/or sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice (including the next
12 # paragraph) shall be included in all copies or substantial portions of the
13 # Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 # SOFTWARE.
23 # Authors: Tom Stellard <thomas.stellard@amd.com>
26 from __future__ import (
27 absolute_import, division, print_function, unicode_literals
29 import re
30 import subprocess
31 from os.path import join
32 from sys import stderr
34 import framework.grouptools as grouptools
35 from framework.core import PIGLIT_CONFIG
36 from .base import Test
38 __all__ = [
39 'OCLConform',
40 'add_oclconform_tests',
44 def get_test_section_name(test):
45 return 'oclconform-{}'.format(test)
48 class OCLConform(Test):
49 def interpret_result(self):
50 if self.result.returncode != 0 or 'FAIL' in self.result.out:
51 self.result.result = 'fail'
52 else:
53 self.result.result = 'pass'
56 def add_sub_test(profile, test_name, subtest_name, subtest):
57 profile.test_list[grouptools.join('oclconform', test_name,
58 subtest_name)] = subtest
61 def add_test(profile, test_name, test):
62 profile.test_list[grouptools.join('oclconform', test_name)] = test
65 def add_oclconform_tests(profile):
66 section_name = 'oclconform'
67 if not PIGLIT_CONFIG.has_section(section_name):
68 return
70 bindir = PIGLIT_CONFIG.get(section_name, 'bindir')
71 options = PIGLIT_CONFIG.options(section_name)
73 tests = (o for o in options if PIGLIT_CONFIG.get(section_name, o) is None)
75 for test in tests:
76 test_section_name = get_test_section_name(test)
77 if not PIGLIT_CONFIG.has_section(test_section_name):
78 print("Warning: no section defined for {}".format(test),
79 file=stderr)
80 continue
82 test_name = PIGLIT_CONFIG.get(test_section_name, 'test_name')
83 should_run_concurrent = PIGLIT_CONFIG.has_option(test_section_name,
84 'concurrent')
85 if PIGLIT_CONFIG.has_option(test_section_name, 'list_subtests'):
86 list_tests = PIGLIT_CONFIG.get(test_section_name,
87 'list_subtests')
88 subtest_regex = PIGLIT_CONFIG.get(test_section_name,
89 'subtest_regex')
90 subtest_regex.encode('unicode_escape')
91 run_subtests = PIGLIT_CONFIG.get(test_section_name, 'run_subtest')
92 list_tests = list_tests.split()
94 subtests = subprocess.check_output(
95 args=list_tests, cwd=bindir).decode('utf-8').split('\n')
96 for subtest in subtests:
97 m = re.match(subtest_regex, subtest)
98 if not m:
99 continue
100 subtest = m.group(1)
101 subtest_command = join(bindir,
102 run_subtests.replace('<subtest>',
103 subtest))
104 add_sub_test(profile, test_name, subtest,
105 OCLConform(command=subtest_command.split(),
106 run_concurrent=should_run_concurrent))
107 else:
108 run_test = PIGLIT_CONFIG.get(test_section_name, 'run_test')
109 add_test(profile, test_name,
110 OCLConform(command=run_test.split(),
111 run_concurrent=should_run_concurrent))