File: piglit_test_tests.py

package info (click to toggle)
piglit 0~git20150829-59d7066-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 39,280 kB
  • sloc: ansic: 191,513; xml: 43,580; cpp: 29,351; python: 18,307; lisp: 8,347; sh: 507; makefile: 17; pascal: 5
file content (129 lines) | stat: -rw-r--r-- 4,954 bytes parent folder | download
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
# 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 exectest module """

from __future__ import print_function, absolute_import

import nose.tools as nt

from framework.tests import utils
from framework.test.base import TestIsSkip
from framework.test.piglit_test import (PiglitBaseTest, PiglitGLTest,
                                        PiglitCLTest)


@utils.no_error
def test_initialize_piglitgltest():
    """test.piglit_test.PiglitGLTest: Class initializes"""
    PiglitGLTest(['/bin/true'])


@utils.no_error
def test_initialize_piglitcltest():
    """test.piglit_test.PiglitCLTest: Class initializes"""
    PiglitCLTest(['/bin/true'])


def test_piglittest_interpret_result():
    """test.piglit_test.PiglitBaseTest.interpret_result(): works no subtests"""
    test = PiglitBaseTest(['foo'])
    test.result['out'] = 'PIGLIT: {"result": "pass"}\n'
    test.result['returncode'] = 0
    test.interpret_result()
    nt.eq_(test.result['result'], 'pass')


def test_piglittest_interpret_result_subtest():
    """test.piglit_test.PiglitBaseTest.interpret_result(): works with subtests"""
    test = PiglitBaseTest(['foo'])
    test.result['out'] = ('PIGLIT: {"result": "pass"}\n'
                          'PIGLIT: {"subtest": {"subtest": "pass"}}\n')
    test.result['returncode'] = 0
    test.interpret_result()
    nt.eq_(test.result['subtest']['subtest'], 'pass')


def test_piglitest_no_clobber():
    """test.piglit_test.PiglitBaseTest.interpret_result(): does not clobber subtest entires"""
    test = PiglitBaseTest(['a', 'command'])
    test.result['out'] = (
        'PIGLIT: {"result": "pass"}\n'
        'PIGLIT: {"subtest": {"test1": "pass"}}\n'
        'PIGLIT: {"subtest": {"test2": "pass"}}\n'
    )
    test.result['returncode'] = 0
    test.interpret_result()

    nt.assert_dict_equal(test.result['subtest'],
                         {'test1': 'pass', 'test2': 'pass'})


def test_piglittest_command_getter_serial():
    """test.piglit_test.PiglitGLTest.command: adds -auto to serial tests"""
    test = PiglitGLTest(['foo'])
    nt.assert_in('-auto', test.command)


def test_piglittest_command_getter_concurrent():
    """test.piglit_test.PiglitGLTest.command: adds -fbo and -auto to concurrent tests"""
    test = PiglitGLTest(['foo'], run_concurrent=True)
    nt.assert_in('-auto', test.command)
    nt.assert_in('-fbo', test.command)


def test_PiglitGLTest_include_and_exclude():
    """test.piglit_test.PiglitGLTest.is_skip(): raises if include and exclude are given."""
    with nt.assert_raises(AssertionError):
        PiglitGLTest(['foo'],
                     require_platforms=['glx'],
                     exclude_platforms=['gbm'])


@utils.not_raises(TestIsSkip)
def test_PiglitGLTest_platform_in_require():
    """test.piglit_test.PiglitGLTest.is_skip(): does not skip if platform is in require_platforms"""
    PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'glx'
    test = PiglitGLTest(['foo'], require_platforms=['glx'])
    test.is_skip()


@nt.raises(TestIsSkip)
def test_PiglitGLTest_platform_not_in_require():
    """test.piglit_test.PiglitGLTest.is_skip(): skips if platform is not in require_platforms"""
    PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'gbm'
    test = PiglitGLTest(['foo'], require_platforms=['glx'])
    test.is_skip()


@nt.raises(TestIsSkip)
def test_PiglitGLTest_platform_in_exclude():
    """test.piglit_test.PiglitGLTest.is_skip(): skips if platform is in exclude_platforms"""
    PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'glx'
    test = PiglitGLTest(['foo'], exclude_platforms=['glx'])
    test.is_skip()


@utils.not_raises(TestIsSkip)
def test_PiglitGLTest_platform_not_in_exclude():
    """test.piglit_test.PiglitGLTest.is_skip(): does not skip if platform is in exclude_platforms"""
    PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'gbm'
    test = PiglitGLTest(['foo'], exclude_platforms=['glx'])
    test.is_skip()