egl: fix _eglMatchDriver() return type
[mesa.git] / .gitlab-ci / tracie / query_traces_yaml.py
1 #!/usr/bin/python3
2
3 # Copyright (c) 2019 Collabora Ltd
4 # Copyright © 2020 Valve Corporation.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a
7 # copy of this software and associated documentation files (the "Software"),
8 # to deal in the Software without restriction, including without limitation
9 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 # and/or sell copies of the Software, and to permit persons to whom the
11 # Software is furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 # OTHER DEALINGS IN THE SOFTWARE.
23 #
24 # SPDX-License-Identifier: MIT
25
26 import argparse
27 import yaml
28 from traceutil import all_trace_type_names, trace_type_from_name
29 from traceutil import trace_type_from_filename
30
31 def trace_devices(trace):
32 return [e['device'] for e in trace['expectations']]
33
34 def cmd_traces_db_gitlab_project_url(args):
35 with open(args.file, 'r') as f:
36 y = yaml.safe_load(f)
37 print(y['traces-db']['gitlab-project-url'])
38
39 def cmd_traces_db_commit(args):
40 with open(args.file, 'r') as f:
41 y = yaml.safe_load(f)
42 print(y['traces-db']['commit'])
43
44 def cmd_traces(args):
45 with open(args.file, 'r') as f:
46 y = yaml.safe_load(f)
47
48 traces = y['traces']
49 traces = filter(lambda t: trace_type_from_filename(t['path']) in args.trace_types,
50 traces)
51 if args.device_name:
52 traces = filter(lambda t: args.device_name in trace_devices(t), traces)
53
54 traces = list(traces)
55
56 if len(traces) == 0:
57 return
58
59 print('\n'.join((t['path'] for t in traces)))
60
61 def cmd_checksum(args):
62 with open(args.file, 'r') as f:
63 y = yaml.safe_load(f)
64
65 traces = y['traces']
66 trace = next(t for t in traces if t['path'] == args.trace_path)
67 expectation = next(e for e in trace['expectations'] if e['device'] == args.device_name)
68
69 print(expectation['checksum'])
70
71 def main():
72 parser = argparse.ArgumentParser()
73 parser.add_argument('--file', required=True,
74 help='the name of the yaml file')
75
76 subparsers = parser.add_subparsers(help='sub-command help')
77
78 parser_traces_db_gitlab_project_url = subparsers.add_parser('traces_db_gitlab_project_url')
79 parser_traces_db_gitlab_project_url.set_defaults(func=cmd_traces_db_gitlab_project_url)
80
81 parser_traces_db_commit = subparsers.add_parser('traces_db_commit')
82 parser_traces_db_commit.set_defaults(func=cmd_traces_db_commit)
83
84 parser_traces = subparsers.add_parser('traces')
85 parser_traces.add_argument('--device-name', required=False,
86 help="the name of the graphics device used to "
87 "produce images")
88 parser_traces.add_argument('--trace-types', required=False,
89 default=",".join(all_trace_type_names()),
90 help="the types of traces to look for in recursive "
91 "dir walks " "(by default all types)")
92 parser_traces.set_defaults(func=cmd_traces)
93
94 parser_checksum = subparsers.add_parser('checksum')
95 parser_checksum.add_argument('--device-name', required=True,
96 help="the name of the graphics device used to "
97 "produce images")
98 parser_checksum.add_argument('trace_path')
99 parser_checksum.set_defaults(func=cmd_checksum)
100
101 args = parser.parse_args()
102 if hasattr(args, 'trace_types'):
103 args.trace_types = [trace_type_from_name(t) for t in args.trace_types.split(",")]
104
105 args.func(args)
106
107 if __name__ == "__main__":
108 main()