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
|
# Copyright (c) 2014 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 glean class. Requires Nose """
from __future__ import absolute_import, division, print_function
import mock
import nose.tools as nt
from framework.options import _Options as Options
from framework.test import GleanTest
from . import utils
from framework.test.base import TestIsSkip
@utils.no_error
def test_initialize_gleantest():
"""test.gleantest.GleanTest: class initializes correctly"""
GleanTest('name')
def test_GLOBAL_PARAMS_assignment():
"""test.gleantest.GleanTest: GLOBAL_PARAMS apply to instances created
after GLABL_PARAMS is set
Specifically this tests for a bug where GLOBAL_PARAMS only affected
instances of GleanTest created after GLOBAL_PARAMS were set, so changing the
GLOBAL_PARAMS value had unexpected results.
If this test passes the GleanTest.command attributes will be the same in
the instance created before the GLOBAL_PARAMS assignment and the one created
after. A failure means the that GLOBAL_PARAMS are not being added to tests
initialized before it is set.
"""
test1 = GleanTest('basic')
GleanTest.GLOBAL_PARAMS = ['--quick']
test2 = GleanTest('basic')
nt.assert_list_equal(test1.command, test2.command)
def test_bad_returncode():
"""test.gleantest.GleanTest: If returncode is 0 the result is 'fail'
Currently clean returns 127 if piglit can't find it's libs (LD_LIBRARY_PATH
isn't set properly), and then marks such tests as pass, when they obviously
are not.
"""
test = GleanTest('basic')
test.result.returncode = 1
test.interpret_result()
nt.assert_equal(test.result.result, 'fail')
@mock.patch('framework.test.gleantest.options.OPTIONS', new_callable=Options)
@nt.raises(TestIsSkip)
def test_is_skip_not_glx(mock_opts):
"""test.gleantest.GleanTest.is_skip: Skips when platform isn't glx"""
mock_opts.env['PIGLIT_PLATFORM'] = 'gbm'
test = GleanTest('foo')
test.is_skip()
@mock.patch('framework.test.gleantest.options.OPTIONS', new_callable=Options)
@utils.not_raises(TestIsSkip)
def test_is_skip_glx(mock_opts):
"""test.gleantest.GleanTest.is_skip: Does not skip when platform is glx"""
mock_opts.env['PIGLIT_PLATFORM'] = 'glx'
test = GleanTest('foo')
test.is_skip()
@mock.patch('framework.test.gleantest.options.OPTIONS', new_callable=Options)
@utils.not_raises(TestIsSkip)
def test_is_skip_glx_egl(mock_opts):
"""test.gleantest.GleanTest.is_skip: Does not skip when platform is mixed_glx_egl
"""
mock_opts.env['PIGLIT_PLATFORM'] = 'mixed_glx_egl'
test = GleanTest('foo')
test.is_skip()
def test_crash():
"""test.gleantest.GleanTest.interpret_result: Crashes are set to crash"""
test = GleanTest('foo')
test.result.returncode = -5
test.interpret_result()
nt.eq_(test.result.result, 'crash')
|