framework: move atexit call closer to init
[piglit.git] / generated_tests / gen_vp_tex.py
blobdc86557a26abb0a547f483530f26161599379663
1 # encoding=utf-8
2 # Copyright © 2016 - 2024 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 """Generate ARBvp tests.
24 Based on a bash generator that performs the same function written by Ian
25 Romanick.
27 """
29 import os
30 import sys
32 from mako import exceptions
34 from templates import template_dir
35 from modules import utils
37 TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
40 def main():
41 """Main function. Generates tests."""
42 dirname = os.path.join('asmparsertest', 'shaders', 'ARBvp1.0')
43 utils.safe_makedirs(dirname)
45 targets_1 = ["1D", "2D", "3D", "CUBE", "RECT", "SHADOW1D", "SHADOW2D"]
47 # The ordering in this loop is weird, it's an artifact of the growth of the
48 # original script and is required to ensure that the names of the tests
49 # don't change
50 for inst in ["TEX", "TXB", "TXD", "TXF", "TXL", "TXP", "TXQ"]:
51 i = 1
52 template = TEMPLATES.get_template('arbvp.mako')
53 for target in targets_1:
54 fname = os.path.join(dirname,
55 "{}-{:0>2d}.txt".format(inst.lower(), i))
56 with open(fname, 'w') as f:
57 try:
58 f.write(template.render_unicode(target=target, inst=inst))
59 except:
60 print(exceptions.text_error_template().render(), file=sys.stderr)
61 raise
62 print(fname)
63 i += 1
65 template = TEMPLATES.get_template('nvvp3.mako')
66 for target in targets_1:
67 fname = os.path.join(dirname,
68 "{}-{:0>2d}.txt".format(inst.lower(), i))
69 with open(fname, 'w') as f:
70 try:
71 f.write(template.render_unicode(target=target, inst=inst))
72 except:
73 print(exceptions.text_error_template().render(), file=sys.stderr)
74 raise
75 print(fname)
76 i += 1
78 template = TEMPLATES.get_template('nvvp3_2.mako')
79 for target in ["CUBE", "RECT"]:
80 fname = os.path.join(dirname,
81 "{}-{:0>2d}.txt".format(inst.lower(), i))
82 with open(fname, 'w') as f:
83 try:
84 f.write(template.render_unicode(target=target, inst=inst))
85 except:
86 print(exceptions.text_error_template().render(), file=sys.stderr)
87 raise
88 print(fname)
89 i += 1
91 template = TEMPLATES.get_template('nvvp3.mako')
92 fname = os.path.join(dirname, "{}-{:0>2d}.txt".format(inst.lower(), i))
93 with open(fname, 'w') as f:
94 try:
95 f.write(template.render_unicode(target="SHADOWRECT", inst=inst))
96 except:
97 print(exceptions.text_error_template().render(), file=sys.stderr)
98 raise
99 print(fname)
100 i += 1
102 template = TEMPLATES.get_template('nvvp3_2.mako')
103 for target in ["SHADOW1D", "SHADOW2D", "SHADOWRECT"]:
104 fname = os.path.join(dirname,
105 "{}-{:0>2d}.txt".format(inst.lower(), i))
106 with open(fname, 'w') as f:
107 try:
108 f.write(template.render_unicode(target=target, inst=inst))
109 except:
110 print(exceptions.text_error_template().render(), file=sys.stderr)
111 raise
112 print(fname)
113 i += 1
116 if __name__ == '__main__':
117 main()