[Piglit] [PATCH 03/24] gen_shader_bit_encoding_test.py: use the if __name__ == __main__ pattern

Dylan Baker baker.dylan.c at gmail.com
Mon Nov 24 09:58:03 PST 2014


v2: - replace gen_shader_bit_encoding: cleanup some styles issues with
      this patch
    - leaves the camel case function names alone (matt, ilia)
    - leaves block comment in test_data

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/gen_shader_bit_encoding_tests.py | 104 ++++++++++++-----------
 1 file changed, 54 insertions(+), 50 deletions(-)

diff --git a/generated_tests/gen_shader_bit_encoding_tests.py b/generated_tests/gen_shader_bit_encoding_tests.py
index 84b9390..f72c465 100644
--- a/generated_tests/gen_shader_bit_encoding_tests.py
+++ b/generated_tests/gen_shader_bit_encoding_tests.py
@@ -127,53 +127,57 @@ requirements = {
 }
 
 
-for api, requirement in requirements.iteritems():
-    version = requirement['version']
-    extensions = [requirement['extension']] if requirement['extension'] else []
-
-    for func, attrib in funcs.iteritems():
-        in_func = attrib['in_func']
-        out_func = attrib['out_func']
-        input_type = attrib['input']
-        output_type = attrib['output']
-
-        for execution_stage in ('vs', 'fs'):
-            file_extension = 'frag' if execution_stage == 'fs' else 'vert'
-
-            for in_modifier_func, modifier_func in modifier_funcs.iteritems():
-                # Modifying the sign of an unsigned number doesn't make sense.
-                if func == 'uintBitsToFloat' and in_modifier_func != '':
-                    continue
-
-                modifier_name = '-' + in_modifier_func if in_modifier_func != '' else ''
-                filename = os.path.join('spec',
-                                        api.lower(),
-                                        'execution',
-                                        'built-in-functions',
-                                        "{0}-{1}{2}.shader_test".format(execution_stage,
-                                                                        func,
-                                                                        modifier_name))
-                print filename
-
-                dirname = os.path.dirname(filename)
-                if not os.path.exists(dirname):
-                    os.makedirs(dirname)
-
-                if in_modifier_func == 'neg':
-                    in_modifier_func = '-'
-                elif in_modifier_func == 'neg_abs':
-                    in_modifier_func = '-abs'
-
-                f = open(filename, 'w')
-                f.write(TEMPLATE.render(version=version,
-                                        extensions=extensions,
-                                        execution_stage=execution_stage,
-                                        func=func,
-                                        modifier_func=modifier_func,
-                                        in_modifier_func=in_modifier_func,
-                                        in_func=in_func,
-                                        out_func=out_func,
-                                        input_type=input_type,
-                                        output_type=output_type,
-                                        test_data=test_data))
-                f.close()
+def main():
+    """main function."""
+    for api, requirement in requirements.iteritems():
+        version = requirement['version']
+        extensions = [requirement['extension']] if requirement['extension'] else []
+
+        for func, attrib in funcs.iteritems():
+            in_func = attrib['in_func']
+            out_func = attrib['out_func']
+            input_type = attrib['input']
+            output_type = attrib['output']
+
+            for execution_stage in ('vs', 'fs'):
+                for in_modifier_func, modifier_func in modifier_funcs.iteritems():
+                    # Modifying the sign of an unsigned number doesn't make sense.
+                    if func == 'uintBitsToFloat' and in_modifier_func != '':
+                        continue
+
+                    modifier_name = '-' + in_modifier_func if in_modifier_func != '' else ''
+                    filename = os.path.join(
+                        'spec',
+                        api.lower(),
+                        'execution',
+                        'built-in-functions',
+                        "{0}-{1}{2}.shader_test".format(execution_stage, func,
+                                                        modifier_name))
+                    print filename
+
+                    dirname = os.path.dirname(filename)
+                    if not os.path.exists(dirname):
+                        os.makedirs(dirname)
+
+                    if in_modifier_func == 'neg':
+                        in_modifier_func = '-'
+                    elif in_modifier_func == 'neg_abs':
+                        in_modifier_func = '-abs'
+
+                    f = open(filename, 'w')
+                    f.write(TEMPLATE.render(version=version,
+                                            extensions=extensions,
+                                            execution_stage=execution_stage,
+                                            func=func,
+                                            modifier_func=modifier_func,
+                                            in_modifier_func=in_modifier_func,
+                                            in_func=in_func,
+                                            out_func=out_func,
+                                            input_type=input_type,
+                                            output_type=output_type,
+                                            test_data=test_data))
+                    f.close()
+
+
+if __name__ == '__main__':
+    main()
-- 
2.1.3



More information about the Piglit mailing list