gl-1.1: Test that unused normal array in ff shader doesn't affect other arrays
[piglit.git] / generated_tests / gen_const_builtin_equal_tests.py
blob2f5ac335759c5823de5c1ac2d226f6a6781d1956
1 # coding=utf-8
2 # Copyright (c) 2010, 2014 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 tests for builtin const equality tests """
24 import re
25 import os
27 from templates import template_file
28 from modules import utils
30 TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]),
31 'template.shader_test.mako')
33 TEST_VECTORS = [
34 ["vec2(3.0, 3.14)",
35 "vec2(-6.0, 7.88)",
36 "bvec2(false, false)"
38 ["vec3(13.4, -0.9, 12.55)",
39 "vec3(13.4, 12.0, -55.3)",
40 "bvec3(true, false, false)"
42 ["vec4(-2.0, 0.0, 0.123, -1000.5)",
43 "vec4(-2.4, 0.0, 0.456, 12.5)",
44 "bvec4(false, true, false, false)"
46 ["ivec2(-8, 12)",
47 "ivec2(-19, 12)",
48 "bvec2(false, true)"
50 ["ivec3(0, 8, 89)",
51 "ivec3(4, -7, 33)",
52 "bvec3(false, false, false)"
54 ["ivec4(11, 1000, 1, -18)",
55 "ivec4(55, 1000, -21, -17)",
56 "bvec4(false, true, false, false)"
58 ["bvec2(true, false)",
59 "bvec2(true, true)",
60 "bvec2(true, false)"
62 ["bvec3(false, true, false)",
63 "bvec3(false, false, true)",
64 "bvec3(true, false, false)"
66 ["bvec4(true, false, false, true)",
67 "bvec4(true, true, false, false)",
68 "bvec4(true, false, true, false)"
73 def main():
74 """ Main function """
75 dirname = os.path.join('spec', 'glsl-1.20', 'execution',
76 'built-in-functions')
77 utils.safe_makedirs(dirname)
79 for test_id, x in enumerate(TEST_VECTORS, start=2):
80 # make equal tests
81 name = os.path.join(
82 dirname,
83 "glsl-const-builtin-equal-{0:02d}.shader_test".format(test_id))
85 print(name)
87 with open(name, 'w') as f:
88 f.write(TEMPLATE.render_unicode(
89 func='equal', input=x[0:2], expected=x[2]))
91 # make notEqual tests
92 name = os.path.join(
93 dirname,
94 "glsl-const-builtin-notEqual-{0:02d}.shader_test".format(test_id))
96 # When generating the notEqual tests, each of the values in the
97 # expected result vector need to be inverted
98 expected = re.sub("true", "FALSE", x[2])
99 expected = re.sub("false", "TRUE", expected)
100 expected = expected.lower()
102 print(name)
104 with open(name, 'w') as f:
105 f.write(TEMPLATE.render_unicode(
106 func='notEqual', input=x[0:2], expected=expected))
109 if __name__ == "__main__":
110 main()