2 # Copyright 2016, 2019 Intel Corporation
3 # Copyright 2014 Advanced Micro Devices, Inc.
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice (including the next
13 # paragraph) shall be included in all copies or substantial portions of the
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 # Authors: Tom Stellard <thomas.stellard@amd.com>
29 from os
.path
import join
30 from sys
import stderr
32 import framework
.grouptools
as grouptools
33 from framework
.core
import PIGLIT_CONFIG
34 from .base
import Test
38 'add_oclconform_tests',
42 def get_test_section_name(test
):
43 return 'oclconform-{}'.format(test
)
46 class OCLConform(Test
):
47 def interpret_result(self
):
48 if self
.result
.returncode
!= 0 or 'FAIL' in self
.result
.out
:
49 self
.result
.result
= 'fail'
51 self
.result
.result
= 'pass'
54 def add_sub_test(profile
, test_name
, subtest_name
, subtest
):
55 profile
.test_list
[grouptools
.join('oclconform', test_name
,
56 subtest_name
)] = subtest
59 def add_test(profile
, test_name
, test
):
60 profile
.test_list
[grouptools
.join('oclconform', test_name
)] = test
63 def add_oclconform_tests(profile
):
64 section_name
= 'oclconform'
65 if not PIGLIT_CONFIG
.has_section(section_name
):
68 bindir
= PIGLIT_CONFIG
.get(section_name
, 'bindir')
69 options
= PIGLIT_CONFIG
.options(section_name
)
71 tests
= (o
for o
in options
if PIGLIT_CONFIG
.get(section_name
, o
) is None)
74 test_section_name
= get_test_section_name(test
)
75 if not PIGLIT_CONFIG
.has_section(test_section_name
):
76 print("Warning: no section defined for {}".format(test
),
80 test_name
= PIGLIT_CONFIG
.get(test_section_name
, 'test_name')
81 should_run_concurrent
= PIGLIT_CONFIG
.has_option(test_section_name
,
83 if PIGLIT_CONFIG
.has_option(test_section_name
, 'list_subtests'):
84 list_tests
= PIGLIT_CONFIG
.get(test_section_name
,
86 subtest_regex
= PIGLIT_CONFIG
.get(test_section_name
,
88 subtest_regex
.encode('unicode_escape')
89 run_subtests
= PIGLIT_CONFIG
.get(test_section_name
, 'run_subtest')
90 list_tests
= list_tests
.split()
92 subtests
= subprocess
.check_output(
93 args
=list_tests
, cwd
=bindir
).decode('utf-8').split('\n')
94 for subtest
in subtests
:
95 m
= re
.match(subtest_regex
, subtest
)
99 subtest_command
= join(bindir
,
100 run_subtests
.replace('<subtest>',
102 add_sub_test(profile
, test_name
, subtest
,
103 OCLConform(command
=subtest_command
.split(),
104 run_concurrent
=should_run_concurrent
))
106 run_test
= PIGLIT_CONFIG
.get(test_section_name
, 'run_test')
107 add_test(profile
, test_name
,
108 OCLConform(command
=run_test
.split(),
109 run_concurrent
=should_run_concurrent
))