2 # Copyright (c) 2015-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 """Tests for the oglconform integration."""
25 from unittest
import mock
29 from framework
import grouptools
30 from framework
import status
32 with mock
.patch('framework.core.PIGLIT_CONFIG.required_get',
33 mock
.Mock(return_value
='piglit.conf.example')):
34 with mock
.patch('subprocess.call', mock
.Mock()):
35 from tests
import oglconform
37 # pylint: disable=protected-access,no-self-use
40 class TestMakeProfile(object):
41 """Tests for the _make_profile function."""
43 def test_basic(self
, mocker
):
44 """tests.oglconform._make_profile: Adds test names"""
45 io_
= mocker
.Mock(wraps
=io
.StringIO(u
'group test.name\n'))
46 io_
.name
= mocker
.Mock()
48 mock_file
= mocker
.MagicMock()
49 mock_file
.__enter
__.return_value
= io_
51 mock_temp
= mocker
.patch
.object(oglconform
.tempfile
,
53 mock_temp
.return_value
= mock_file
55 mocker
.patch('subprocess.call', mocker
.Mock())
56 profile
= oglconform
._make
_profile
()
58 name
= grouptools
.join('oglconform', 'group', 'test.name')
59 assert name
in profile
.test_list
61 def test_missing(self
, mocker
):
62 """tests.oglconform._make_profile: handles missing groups"""
63 io_
= mocker
.Mock(wraps
=io
.StringIO(u
'test.name\n'))
64 io_
.name
= mocker
.Mock()
66 mock_file
= mocker
.MagicMock()
67 mock_file
.__enter
__.return_value
= io_
69 mock_temp
= mocker
.patch
.object(oglconform
.tempfile
,
71 mock_temp
.return_value
= mock_file
73 mocker
.patch('subprocess.call', mocker
.Mock())
74 oglconform
._make
_profile
()
77 class TestOGLCTest(object):
78 """Tests for the OGLCTest class."""
80 def test_command(self
):
81 """tests.oglconform.OGLCtest.command: value is as expected"""
82 expected
= ['piglit.conf.example', '-minFmt', '-v', '4', '-test',
85 test
= oglconform
.OGLCTest('group', 'test')
86 assert expected
== test
.command
88 class TestInterpretResult(object):
89 """Tests for the interpret_result method."""
92 """tests.oglconform.OGLCtest.interpret_result: status is pass when
95 test
= oglconform
.OGLCTest('group', 'test')
96 test
.result
.returncode
= 0
103 test
.interpret_result()
105 assert test
.result
.result
is status
.PASS
107 def test_skip_from_not_run(self
):
108 """tests.oglconform.OGLCtest.interpret_result: status is skip when
111 test
= oglconform
.OGLCTest('group', 'test')
112 test
.result
.returncode
= 0
119 test
.interpret_result()
121 assert test
.result
.result
is status
.SKIP
124 """tests.oglconform.OGLCtest.interpret_result: status is fail
127 test
= oglconform
.OGLCTest('group', 'test')
128 test
.result
.returncode
= 0
129 test
.interpret_result()
131 assert test
.result
.result
is status
.FAIL
133 def test_crash(self
):
134 """tests.oglconform.OGLCtest.interpret_result: status is crash if
137 test
= oglconform
.OGLCTest('group', 'test')
138 test
.result
.returncode
= -1
139 test
.interpret_result()
141 assert test
.result
.result
is status
.CRASH
143 @pytest.mark
.parametrize("out", [
144 'no test in schedule is compat',
145 'GLSL 1.30 is not supported',
146 'GLSL 1.40 is not supported',
147 'GLSL 1.50 is not supported',
148 'GLSL 3.30 is not supported',
149 'GLSL 3.40 is not supported',
150 'GLSL 3.50 is not supported',
151 'wont be scheduled due to lack of compatible fbconfig',
153 def test_skip_from_re(self
, out
):
154 test
= oglconform
.OGLCTest('group', 'value')
155 test
.result
.out
= out
156 test
.result
.returncode
= 0
157 test
.interpret_result()
158 assert test
.result
.result
== 'skip'