[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30251] branches/soc-2010-leifandersen/ tests/render: 1.

Leif Andersen leif.a.andersen at gmail.com
Tue Jul 13 03:40:52 CEST 2010


Revision: 30251
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30251
Author:   leifandersen
Date:     2010-07-13 03:40:50 +0200 (Tue, 13 Jul 2010)

Log Message:
-----------
1.  Added better hash suppoert, with several flags that can run hash comparison tests.

2.  Moved the deformtest to anim (missed that one)

3.  Changed the contents of hashcodes.txt

Modified Paths:
--------------
    branches/soc-2010-leifandersen/tests/render/hashcodes.txt
    branches/soc-2010-leifandersen/tests/render/run.py

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/render/anim/deformtest.blend

Removed Paths:
-------------
    branches/soc-2010-leifandersen/tests/render/deformtest.blend

Copied: branches/soc-2010-leifandersen/tests/render/anim/deformtest.blend (from rev 30235, branches/soc-2010-leifandersen/tests/render/deformtest.blend)
===================================================================
(Binary files differ)

Deleted: branches/soc-2010-leifandersen/tests/render/deformtest.blend
===================================================================
(Binary files differ)

Modified: branches/soc-2010-leifandersen/tests/render/hashcodes.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/render/hashcodes.txt	2010-07-13 00:57:19 UTC (rev 30250)
+++ branches/soc-2010-leifandersen/tests/render/hashcodes.txt	2010-07-13 01:40:50 UTC (rev 30251)
@@ -1,54 +1,30 @@
-CtrlObject.blend = -1
-Raptor_radio_ray_env.blend = 33982623
-allselect.blend = 13357554
-arealight.blend = 12065140
-array3.blend = 143049984
-bowl.blend = 6283770
-camera.blend = 1579067
-compo_idmask_cubes.blend = 29988479
-compo_map_uv.blend = 38220279
-compo_map_uv_cubes.blend = 29678781
-compo_map_zcombine_cubes.blend = 36673579
-composite_image.blend = 218981041
-composite_layers.blend = 26746916
-controller2.blend = 3687663
-cubesphere.blend = 3481153
-displace.blend = 15286177
-dolphin.blend = 47212314
-driven_hand.blend = 9502911
-driver-object-eyes.blend = 125922590
-dupliverts.blend = 6111411
-flaretest.blend = 90616561
-glass.blend = 25052476
-hairguide.blend = 12361972
-halostep.blend = 18936191
-knight.blend = 29232841
-lostride.blend = 18995802
-luxo.blend = 1283166
-mancandy_actiondeform.blend = 58838400
-mancandy_matching.blend = 39225600
-mirror_texture.blend = 18745929
-monkey_cornelius.blend = 31411894
-monkey_cornelius_bake.blend = 31288006
-monkey_cornelius_compo.blend = 31525697
-monkey_cornelius_light-passes.blend = 36589238
-monkey_cornelius_passes.blend = 29445852
-monkey_cornelius_shadbuf.blend = 113297051
-motionblender.blend = 2140986
-motor9.blend = 22404981
-only_shadow_lamp.blend = 15217479
-only_shadow_material.blend = 528474
-pathJumper.blend = 0
-refract_monkey.blend = 53649320
-relative.blend = 1758561
-robo_ao.blend = 29737827
-sequence.blend = 0
-softbody_basics.blend = -1
-softbody_curve_lattice.blend = 19242895
-sss.blend = 80845952
-stride_bone.blend = -1
-teapot_envmap.blend = 68155147
-teapot_soft.blend = 16755754
-vectorblur.blend = 51362950
-windows_tra_shadow.blend = 13032008
-
+Image: Raptor_radio_ray_env.blend 33982623
+Image: arealight.blend 12065140
+Image: compo_idmask_cubes.blend 29988479
+Image: compo_map_uv.blend 38220279
+Image: compo_map_uv_cubes.blend 29678781
+Image: compo_map_zcombine_cubes.blend 36673579
+Image: composite_image.blend 218981041
+Image: composite_layers.blend 26746916
+Image: displace.blend 15286177
+Image: dupliverts.blend 6111411
+Image: flaretest.blend 90616561
+Image: flippedmatrixes.blend 32615702
+Image: halostep.blend 18936191
+Image: mirror_texture.blend 18745929
+Image: monkey_cornelius.blend 31411894
+Image: monkey_cornelius_bake.blend 31288006
+Image: monkey_cornelius_compo.blend 31525697
+Image: monkey_cornelius_light-passes.blend 36589238
+Image: monkey_cornelius_passes.blend 29445852
+Image: monkey_cornelius_shadbuf.blend 113297051
+Image: motor9.blend 22404981
+Image: nodelib.blend 78437901
+Image: only_shadow_lamp.blend 15217479
+Image: only_shadow_material.blend 528474
+Image: refract_monkey.blend 53649320
+Image: sss.blend 80845952
+Image: teapot_envmap.blend 68155147
+Image: teapot_soft.blend 16755754
+Image: text-regression.blend 312492495
+Image: windows_tra_shadow.blend 13032008
\ No newline at end of file

Modified: branches/soc-2010-leifandersen/tests/render/run.py
===================================================================
--- branches/soc-2010-leifandersen/tests/render/run.py	2010-07-13 00:57:19 UTC (rev 30250)
+++ branches/soc-2010-leifandersen/tests/render/run.py	2010-07-13 01:40:50 UTC (rev 30251)
@@ -25,6 +25,9 @@
 HTML_OUTPUT = sys.path[0]
 GOOD_BLENDER_BIN = 'blender'
 BUILDING_TESTS = False
+HASHCODE_TEST = False
+HASHCODE_FILE = os.path.join(sys.path[0], 'hashcodes.txt')
+GET_HASHCODES = False
 
 HELP = '''Help to come'''
 
@@ -64,7 +67,7 @@
         self.good_hash = good_hash
         self.blend_path = blend_path
         self.test_path = test_path
-        self.mode = 'hash'
+        self.mode = 'Hash'
 
     def setup_image(self, blend_path, good_path, test_path):
         '''Sets up a test case, with the blend_path, the known good path, and the test path
@@ -152,6 +155,25 @@
                 self.passed = False
             return self.passed
 
+    def hash_test(self):
+        if self.test_image != None:
+            if self.good_hash == None:
+                if self.good_image != None:
+                    self.good_hash = self.generate_hash(self.good_image)
+                else:
+                    self.message = 'No Good Hash given, or Good Image given'
+                    self.passed = False
+                    return
+            if self.test_hash == None:
+                self.test_hash = self.generate_hash(self.test_image)
+            if self.pixel_count == None:
+                self.pixel_count = self.test_image.size[0] * self.test_image.size[1]
+            self.diff_hash = abs(self.test_hash - self.good_hash)
+            if self.diff_hash < self.pixel_count/10:
+                self.passed = True
+            else:
+                self.passed = False
+
     def save_diff(self, output_path):
         '''Saves the diff image to output_path'''
         if self.diff_image != None:
@@ -298,7 +320,7 @@
             self.diff_sum = 0
             self.difference = 0
             self.message = "Failed to render"
-            self.test_hash = -1
+            self.test_hash = None
 
     def image_test(self):
         ''''''
@@ -336,7 +358,9 @@
             self.diff_sum = self.diff_sum_arr[0]
             self.bad_pixels = self.bad_pixels_arr[0]
             self.pixel_range = self.pixel_range_arr[0]
-            self.pixel_count = self.pixel_count_arr[0]
+            self.pixel_count = 0
+            for num in self.pixel_count:
+                self.pixel_count+=num
             
             self.passed = True
             fail_count = 0
@@ -347,6 +371,27 @@
             if fail_count > frames/50:
                 self.passed = False
 
+    def hash_test(self):
+        if self.test_image != None:
+            if self.good_hash == None:
+                if self.good_image != None:
+                    self.good_hash = self.generate_hash(self.good_animation)
+                else:
+                    self.passed = False
+                    self.message = 'No Good Hash or Good Image provided'
+                    return
+            if self.test_hash == None:
+                self.generate_hash(self.test_animation)
+            if self.pixel_count == None:
+                self.pixel_count = 0
+                for image in self.test_animation:
+                    self.pixel_count+=image.size[0] * image.size[1]
+            self.diff_hash = abs(self.test_hash - self.good_hash)
+            if self.diff_hash < self.pixel_count/10:
+                self.passed = True
+            else:
+                self.passed = False
+
     def save_diff(self, output_path):
         ''''''
         if self.diff_image != None:
@@ -384,6 +429,39 @@
             cases.append(test_case)
     return cases
 
+def get_hash_cases(blend_file_folder, hash_file, output_folder):
+    cases = []
+    image_cases = []
+    animation_cases = []
+    file = open(hash_file, 'r')
+    for line in file:
+        (case_type, blend_file, hashcode) = line.split()
+        if case_type == 'Image:':
+            image_cases.append((blend_file, hashcode))
+        if case_type == 'Animation:':
+            animation_cases.append((blend_file, hashcode))
+    for filename in os.listdir(blend_file_folder):
+        if filename.find('.blend') != -1:
+            (directory, blend_name) = os.path.split(filename)
+            for (name, code) in image_cases:
+                if name == blend_name:
+                    blend_path = os.path.join(blend_file_folder, filename)
+                    hash_code = code
+                    test_path = os.path.join(output_folder, string.replace(filename, '.blend', ''))
+                    test_case = ImageTestCase()
+                    test_case.setup_hash(blend_path, int(hash_code), test_path)
+                    cases.append(test_case)
+            for (name, code) in animation_cases:
+                if name == blend_name:
+                    blend_path = os.path.join(blend_file_folder, filename)
+                    hash_coe = code
+                    test_path = os.path.join(output_folder, string.replace(filename, '.blend', ''))
+                    test_case = AnimationTestCase()
+                    test_case.setup_hash(blend_path, int(hash_code), test_path)
+                    cases.append(test_case)
+    file.close()
+    return cases
+
 def get_cases(blend_file_folder, good_folder, output_folder):
     '''Returns all of the blend files in the folder'''
     cases = []
@@ -391,11 +469,6 @@
     cases+=get_animation_cases(os.path.join(blend_file_folder, 'anim'), os.path.join(blend_file_folder, 'anim'), output_folder)
     return cases
 
-def get_hashcodes(filename):
-    file = open(filename, 'r')
-
-    file.close()
-
 def console_output(cases):
     '''Displays the final output to the console.  The output that will be shown if the -v flag isn't used'''
     failed = []
@@ -407,7 +480,11 @@
     for test_case in cases:
         if test_case.passed == False:
             failed.append(test_case)
-    
+
+    if GET_HASHCODES:
+        for case in cases:
+            print case.ID + ':', case.name, case.test_hash    
+
     if len(failed) > 0:
         print "The following tesets failed:"
         for test_case in failed:
@@ -678,7 +755,7 @@
             case = AnimationTestCase()
             case.setup_image(argv_path, os.path.join(argv_directory, string.replace(argv_file, '.blend', '')), os.path.join(argv_directory, 'output', string.replace(argv_file, '.blend', '')))
             cases.append(case)
-        if arg == '--run-animations':
+        if arg == '--with-animations':
             RUN_IMAGES_AND_ANIMATIONS = True
             RUN_IMAGES = False
         if arg == '--image' and len(sys.argv) > argv_i:
@@ -698,6 +775,15 @@
             GOOD_FOLDER = ''
             ANIM_GOOD_FOLDER = ''

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list