gitlab-ci: Automated testing with OpenGL traces
[mesa.git] / .gitlab-ci / tracie / traceutil.py
1 # Copyright (c) 2019 Collabora Ltd
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the "Software"),
5 # to deal in the Software without restriction, including without limitation
6 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 # and/or sell copies of the Software, and to permit persons to whom the
8 # Software is furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included
11 # in all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
17 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19 # OTHER DEALINGS IN THE SOFTWARE.
20 #
21 # SPDX-License-Identifier: MIT
22
23 import os
24 from pathlib import Path
25 from enum import Enum, auto
26
27 class TraceType(Enum):
28 UNKNOWN = auto()
29 APITRACE = auto()
30 RENDERDOC = auto()
31 TESTTRACE = auto()
32
33 _trace_type_info_map = {
34 TraceType.APITRACE : ("apitrace", ".trace"),
35 TraceType.RENDERDOC : ("renderdoc", ".rdc"),
36 TraceType.TESTTRACE : ("testtrace", ".testtrace")
37 }
38
39 def all_trace_type_names():
40 s = []
41 for t,(name, ext) in _trace_type_info_map.items():
42 if t != TraceType.UNKNOWN:
43 s.append(name)
44 return s
45
46 def trace_type_from_name(tt_name):
47 for t,(name, ext) in _trace_type_info_map.items():
48 if tt_name == name:
49 return t
50
51 return TraceType.UNKNOWN
52
53 def trace_type_from_filename(trace_file):
54 for t,(name, ext) in _trace_type_info_map.items():
55 if trace_file.endswith(ext):
56 return t
57
58 return TraceType.UNKNOWN