perf/pixel-rate: new pixel throughput microbenchmark
[piglit.git] / unittests / framework / replay / test_query_traces_yaml.py
blobae039b7e1e0916ac459e3d390b260d56fd2bf64f
1 # coding=utf-8
3 # Copyright © 2020 Valve Corporation.
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 # OTHER DEALINGS IN THE SOFTWARE.
23 # SPDX-License-Identifier: MIT
26 """Tests for replayer's query_traces_yaml module."""
28 import pytest
30 from framework import exceptions
32 from framework.replay import query_traces_yaml as qty
35 YAML_DATA = [["", {}],
36 ["""
37 - First
38 - Second
39 """,
40 ["First", "Second"]],
41 ["""
42 a: 1
44 c: 2
45 """,
46 {"a": 1, "b": {"c": 2}}],
49 TRACES_DATA = {"traces": {
50 "glmark2/desktop-blur-radius=5:effect=blur:passes=1:separable=true:windows=4.rdc": {
51 "gl-vmware-llvmpipe": {
52 "checksum": "8867f3a41f180626d0d4b7661ff5c0f4"
55 "glxgears/glxgears-2.trace": {
56 "gl-vmware-llvmpipe": {
57 "checksum": "f8eba0fec6e3e0af9cb09844bc73bdc7"
59 "gl-virgl": {
60 "checksum": "f8eba0fec6e3e0af9cb09844bc73bdc7"
63 "pathfinder/demo.trace": {
64 "gl-vmware-llvmpipe": {
65 "checksum": "e624d76c70cc3c532f4f54439e13659a"
68 "KhronosGroup-Vulkan-Tools/amd/polaris10/vkcube.gfxr": {
69 "vk-amd-polaris10": {
70 "checksum": "917cbbf4f09dd62ea26d247a1c70c16e"
73 "pathfinder/demo2.trace": {
74 "gl-vmware-llvmpipe": {
75 "label": ["skip"]
81 @pytest.mark.raises(exception=exceptions.PiglitFatalError)
82 def test_load_yaml_PiglitFatalError():
83 """query_traces_yaml.load_yaml: Raise PiglitFatalError on invalid YAML"""
84 y = qty.load_yaml("*** this is not YAML ***")
87 def test_load_yaml_basic():
88 """query_traces_yaml.load_yaml: Load some basic YAML documents"""
90 for i in YAML_DATA:
91 y = qty.load_yaml(i[0])
93 assert i[1] == y
96 @pytest.mark.raises(exception=TypeError)
97 @pytest.mark.parametrize("trace, device", [
98 ([], None),
99 ({"one"}, None),
100 ({"one", "another"}, None),
102 def test_trace_checksum_TypeError(trace, device):
103 """query_traces_yaml.trace_checksum: Raise TypeError on invalid trace"""
104 c = qty.trace_checksum(trace, device)
107 @pytest.mark.parametrize("trace, device, expected", [
108 ({}, None, ''),
109 ({"one": 1}, None, ''),
110 ({"gl-vmware-lvmpipe": {}}, "gl-vmware-lvmpipe", ''),
111 ({"gl-vmware-lvmpipe": {"checksum": "a checksum"}},
112 "gl-vmware-lvmpipe", "a checksum"),
113 ({"gl-vmware-lvmpipe": {"checksum": "a checksum"},
114 "vk-intel-anv": {"checksum": "another checksum"}},
115 "vk-intel-anv", "another checksum")
117 def test_trace_checksum_basic(trace, device, expected):
118 """query_traces_yaml.trace_checksum: Get checksum from some basic traces"""
119 assert expected == qty.trace_checksum(trace, device)
122 @pytest.mark.raises(exception=TypeError)
123 @pytest.mark.parametrize("yaml", [
124 (8),
125 ({"traces-db": "one"}),
127 def test_download_url_TypeError(yaml):
128 """query_traces_yaml.download_url: Raise TypeError on invalid YAML"""
129 u = qty.download_url(yaml)
132 @pytest.mark.parametrize("yaml, expected", [
133 ({}, None),
134 ({"traces-db": {"one": 1}}, None),
135 ({"traces-db": {"download-url": "an url"}}, "an url"),
136 ({"traces-db": {"one": 1, "download-url": "an url"}}, "an url"),
138 def test_download_url_basic(yaml, expected):
139 """query_yamls_yaml.download_url: Get download url from some basic YAML with a trace-db entry"""
140 assert expected == qty.download_url(yaml)
143 @pytest.mark.raises(exception=AttributeError)
144 @pytest.mark.parametrize("yaml, ext, device, checksum", [
145 (8, ".trace", "gl-vmware-llvmpipe", True),
146 (TRACES_DATA, {}, None, False),
148 def test_traces_AttributeError(yaml, ext, device, checksum):
149 """query_traces_yaml.traces: Raise AttributeError on invalid parameters"""
150 t = list(qty.traces(yaml, ext, device, checksum))
153 @pytest.mark.raises(exception=AttributeError)
154 @pytest.mark.parametrize("yaml, ext, device, checksum", [
155 ({"traces": "one"}, ".trace", "gl-vmware-llvmpipe", True),
156 ({"traces": ["one"]}, ".trace", "gl-vmware-llvmpipe", True),
157 ({"traces": [{"path": 8}]}, ".trace", "gl-vmware-llvmpipe", True),
159 def test_traces_TypeError(yaml, ext, device, checksum):
160 """query_traces_yaml.traces: Raise TypeError on invalid YAML"""
161 t = list(qty.traces(yaml, ext, device, checksum))
164 @pytest.mark.parametrize("yaml, ext, device, checksum, expected", [
165 ({}, ".trace", "gl-vmware-llvmpipe", True, []),
166 ({"traces": {}}, ".trace", "gl-vmware-llvmpipe", True, []),
167 (TRACES_DATA, "", "gl-virgl", False, []),
168 (TRACES_DATA, ".rdc", "gl-virgl", False, []),
169 (TRACES_DATA, ".trace", "gl-virgl", False,
170 [{"path": "glxgears/glxgears-2.trace"}]),
171 (TRACES_DATA, ".rdc,.trace", "gl-vmware-llvmpipe", False,
172 [{"path": "glmark2/desktop-blur-radius=5:effect=blur:passes=1:separable=true:windows=4.rdc"},
173 {"path": "glxgears/glxgears-2.trace"},
174 {"path": "pathfinder/demo.trace"}]),
175 (TRACES_DATA, ".trace", None, False,
176 [{"path": "glxgears/glxgears-2.trace"},
177 {"path": "pathfinder/demo.trace"}]),
178 (TRACES_DATA, ".gfxr", "vk-amd-polaris10", True,
179 [{"checksum": "917cbbf4f09dd62ea26d247a1c70c16e",
180 "path": "KhronosGroup-Vulkan-Tools/amd/polaris10/vkcube.gfxr"}]),
181 (TRACES_DATA, ".gfxr", None, True,
182 [{"checksum": "",
183 "path": "KhronosGroup-Vulkan-Tools/amd/polaris10/vkcube.gfxr"}]),
185 def test_traces_basic(yaml, ext, device, checksum, expected):
186 """query_traces_yaml.traces: Get traces lists from some basic yamls"""
187 assert expected == list(qty.traces(yaml, ext, device, checksum))