[Piglit] [PATCH 07/24] gen_shader_bit_encoding_tests.py: move dirname assignment up in loops

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


The directory name doesn't depend on values in the inner loops; so we
can generate it once and check for its existence once.

v2: - add this patch

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

diff --git a/generated_tests/gen_shader_bit_encoding_tests.py b/generated_tests/gen_shader_bit_encoding_tests.py
index 5d5ee8a..8c48f70 100644
--- a/generated_tests/gen_shader_bit_encoding_tests.py
+++ b/generated_tests/gen_shader_bit_encoding_tests.py
@@ -136,6 +136,11 @@ def main():
         version = requirement['version']
         extensions = [requirement['extension']] if requirement['extension'] else []
 
+        dirname = os.path.join('spec', api.lower(), 'execution',
+                               'built-in-functions')
+        if not os.path.exists(dirname):
+            os.makedirs(dirname)
+
         for func, attrib in FUNCS.iteritems():
             in_func = attrib['in_func']
             out_func = attrib['out_func']
@@ -150,18 +155,11 @@ def main():
 
                     modifier_name = '-' + in_modifier_func if in_modifier_func != '' else ''
                     filename = os.path.join(
-                        'spec',
-                        api.lower(),
-                        'execution',
-                        'built-in-functions',
+                        dirname,
                         "{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':
-- 
2.1.3



More information about the Piglit mailing list