1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# Copyright (c) 2015 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Tests for the oglconform integration."""
from StringIO import StringIO
import mock
import nose.tools as nt
from . import utils
from framework import grouptools
with mock.patch('framework.core.PIGLIT_CONFIG.required_get',
mock.Mock(return_value='piglit.conf.example')):
with mock.patch('subprocess.call', mock.Mock()):
from tests import oglconform
# pylint: disable=protected-access,invalid-name,line-too-long
@mock.patch.object(oglconform.tempfile, 'NamedTemporaryFile')
def test_make_profile(mock_temp):
"""tests.oglconform._make_profile: Adds test names"""
io_ = StringIO('group test.name\n')
io_.name = mock.Mock()
mock_file = mock.MagicMock()
mock_file.__enter__.return_value = io_
mock_temp.return_value = mock_file
with mock.patch('subprocess.call', mock.Mock()):
profile = oglconform._make_profile()
name = grouptools.join('oglconform', 'group', 'test.name')
nt.ok_(name in profile.test_list,
msg='{} not in {}'.format(name, profile.test_list.keys()))
@utils.not_raises(ValueError)
@mock.patch.object(oglconform.tempfile, 'NamedTemporaryFile')
def test_make_profile_missing(mock_temp):
"""tests.oglconform._make_profile: handles missing groups"""
io_ = StringIO('test.name\n')
io_.name = mock.Mock()
mock_file = mock.MagicMock()
mock_file.__enter__.return_value = io_
mock_temp.return_value = mock_file
with mock.patch('subprocess.call', mock.Mock()):
oglconform._make_profile()
def test_oglctest_command():
"""tests.oglconform.OGLCtest.command: value is as expected"""
expected = ['piglit.conf.example', '-minFmt', '-v', '4', '-test', 'group',
'test']
test = oglconform.OGLCTest('group', 'test')
nt.eq_(expected, test.command)
def test_oglctest_interpret_result_pass():
"""tests.oglconform.OGLCtest.interpret_result: status is pass when expected
"""
test = oglconform.OGLCTest('group', 'test')
test.result.returncode = 0
test.result.out = (
'Another line\n'
'Total Passed : 1\n'
'Total Failed : 0\n'
'Total Not run: 0\n'
)
test.interpret_result()
nt.eq_(test.result.result, 'pass')
def test_oglctest_interpret_result_skip():
"""tests.oglconform.OGLCtest.interpret_result: status is skip when tests not run"""
test = oglconform.OGLCTest('group', 'test')
test.result.returncode = 0
test.result.out = (
'Another line\n'
'Total Failed : 0\n'
'Total Passed : 0\n'
'Total Not run: 1\n'
)
test.interpret_result()
nt.eq_(test.result.result, 'skip')
@utils.nose_generator
def test_oglctest_interpret_result_skip_re():
"""Generate tests for various skip tests."""
values = [
'no test in schedule is compat',
'GLSL 1.30 is not supported',
'GLSL 1.40 is not supported',
'GLSL 1.50 is not supported',
'GLSL 3.30 is not supported',
'GLSL 3.40 is not supported',
'GLSL 3.50 is not supported',
'wont be scheduled due to lack of compatible fbconfig'
]
def test(out):
"""The actual test."""
test = oglconform.OGLCTest('group', 'value')
test.result.out = out
test.result.returncode = 0
test.interpret_result()
nt.eq_(test.result.result, 'skip')
for each in values:
test.description = ('tests.oglconform.OGLCTest.interpret_result: '
'"{}" in result.out makes status skip'.format(each))
yield test, each
def test_oglctest_interpret_result_fail():
"""tests.oglconform.OGLCtest.interpret_result: status is fail otherwise"""
test = oglconform.OGLCTest('group', 'test')
test.result.returncode = 0
test.interpret_result()
nt.eq_(test.result.result, 'fail')
def test_oglctest_interpret_result_crash():
"""tests.oglconform.OGLCtest.interpret_result: status is crash if returncode is not 0"""
test = oglconform.OGLCTest('group', 'test')
test.interpret_result()
nt.eq_(test.result.result, 'crash')
|