cl: Don't use device_infos if num_device_infos == 0
[piglit.git] / tests / find_static_tests.py
blob08f9d56f6f804accdbdc76878a8d764a7789b0b5
1 # encoding=utf-8
2 # Copyright © 2018-2019 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 # SOFTWARE.
22 """Script that finds all static tests of one kind or another."""
24 import argparse
25 import io
26 import os
29 def main():
30 parser = argparse.ArgumentParser()
31 parser.add_argument('sourcedir')
32 parser.add_argument(
33 'mode',
34 choices=['shader', 'glslparser', 'asmparser', 'program', 'vkrunner'])
35 parser.add_argument('output')
36 args = parser.parse_args()
38 if args.mode == 'asmparser':
39 exts = ['.txt']
40 directory = os.path.join(args.sourcedir, 'asmparsertest', 'shaders')
41 elif args.mode == 'glslparser':
42 exts = ['.frag', '.vert', '.goem', '.tess', 'tesc', '.comp']
43 directory = args.sourcedir
44 elif args.mode == 'shader':
45 exts = ['.shader_test']
46 directory = args.sourcedir
47 elif args.mode == 'vkrunner':
48 exts = ['.vk_shader_test']
49 directory = args.sourcedir
50 elif args.mode == 'program':
51 exts = ['.program_test']
52 directory = args.sourcedir
54 files = []
55 for dirpath, _, filenames in os.walk(directory):
56 for filename in filenames:
57 if os.path.splitext(filename)[1] in exts:
58 name = os.path.join(dirpath, filename)
59 files.append(name)
61 if os.path.exists(args.output):
62 with io.open(args.output, 'rt', encoding='utf-8') as f:
63 existing = f.read().rstrip().split('\n')
64 else:
65 existing = []
67 if sorted(files) != sorted(existing):
68 with io.open(args.output, 'wt', encoding='utf-8') as f:
69 for filename in files:
70 f.write(filename)
71 f.write('\n')
74 if __name__ == '__main__':
75 main()