2 # Copyright 2014-2016, 2019 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 """Piglit integrations for Crucible Test Suite.
24 upstream: https://gitlab.freedesktop.org/mesa/crucible/
33 from lxml
import etree
35 import xml
.etree
.ElementTree
as etree
37 from framework
import grouptools
, backends
, core
, exceptions
38 from framework
import status
39 from framework
.profile
import TestProfile
, Test
43 crucible_bin
= core
.get_option('PIGLIT_CRUCIBLE_BIN',
48 class CrucibleTest(Test
):
49 """Test representation for Crucible"""
50 def __init__(self
, case_name
):
51 self
.__out
_xml
= tempfile
.NamedTemporaryFile(delete
=True).name
52 command
= [crucible_bin
, 'run',
53 '--junit-xml={}'.format(self
.__out
_xml
), case_name
]
54 self
._case
= case_name
55 super(CrucibleTest
, self
).__init
__(command
)
57 def interpret_result(self
):
59 test
= backends
.junit
.REGISTRY
.load(self
.__out
_xml
, 'none')
60 result
= test
.get_result(next(test
.tests
.keys()))
61 self
.result
.result
= result
.name
62 super(CrucibleTest
, self
).interpret_result()
63 except etree
.ParseError
:
64 # This error is what ElementTree will generate, and is the parent
65 # of what lxml will generate.
66 self
.result
.result
= status
.CRASH
68 os
.remove(self
.__out
_xml
)
70 def gen_caselist_txt(bin_
):
71 with
open('crucible.txt', 'w') as d
:
72 subprocess
.check_call(
75 assert os
.path
.exists('crucible.txt')
78 def _populate_profile():
79 profile
= TestProfile()
80 case_file
= gen_caselist_txt(crucible_bin
)
81 with
open(case_file
, 'r') as caselist_file
:
82 for i
, line
in enumerate(caselist_file
):
84 piglit_name
= case
.replace('.', grouptools
.SEPARATOR
)
85 profile
.test_list
[piglit_name
] = CrucibleTest(case
)
86 os
.remove('crucible.txt')
89 profile
= _populate_profile()