[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29549] branches/soc-2010-leifandersen/ tests/pyunit/ops/physics: 1.

Leif Andersen leif.a.andersen at gmail.com
Fri Jun 18 21:50:41 CEST 2010


Revision: 29549
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29549
Author:   leifandersen
Date:     2010-06-18 21:50:40 +0200 (Fri, 18 Jun 2010)

Log Message:
-----------
1.  Started filling in image comparison tests.  Thusfar, I've tried two approaches.

a.  Summing up all of the pixels, of all three bands, and comparing it to a known good image.
b.  Summing up the bands seperatly, and comparing it to a known good picture.

The first one is much quicker.  I'm also thinking about seperating them into buckets (eg.  Comparing each couple of thousand pixels in discreet chuncks), that way when I allow for a margin of error, it would produce a more acurate picture.

2.  I've spent far too much time trying to get CTest to run multiple commands in a single test, thusfar with little success.  Hopefully I'll get something done soon, otherwise there will be a lot of extranios tests.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/tests/pyunit/ops/physics/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/pyunit/ops/physics/particle_image.py

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/pyunit/ops/physics/cube_hair.png
    branches/soc-2010-leifandersen/tests/pyunit/ops/physics/runtests.cmake

Modified: branches/soc-2010-leifandersen/tests/pyunit/ops/physics/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/ops/physics/CMakeLists.txt	2010-06-18 16:07:47 UTC (rev 29548)
+++ branches/soc-2010-leifandersen/tests/pyunit/ops/physics/CMakeLists.txt	2010-06-18 19:50:40 UTC (rev 29549)
@@ -1,5 +1,9 @@
 ADD_TEST(Ops_Particle_Test ${Blender_BINARY_DIR}/bin/blender -P ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/particle.py)
-SET_TESTS_PROPERTIES(Ops_Particle_Test PROPERTIES PASS_REGULAR_EXPRESSION "OK")
 
-ADD_TEST(Ops_Particle_Test_Image_Compare python ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/particle_image.py)
-SET_TESTS_PROPERTIES(Ops_Particle_Test_Image_Compare PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+ADD_TEST(NAME Ops_Particle_Test_Image_Compare
+	COMMAND ${CMAKE_COMMAND} -P ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/runtests.cmake
+)
+
+SET_TESTS_PROPERTIES(Ops_Particle_Test Ops_Particle_Test_Image_Compare 
+	PROPERTIES PASS_REGULAR_EXPRESSION "OK"
+)

Added: branches/soc-2010-leifandersen/tests/pyunit/ops/physics/cube_hair.png
===================================================================
(Binary files differ)


Property changes on: branches/soc-2010-leifandersen/tests/pyunit/ops/physics/cube_hair.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: branches/soc-2010-leifandersen/tests/pyunit/ops/physics/particle_image.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/ops/physics/particle_image.py	2010-06-18 16:07:47 UTC (rev 29548)
+++ branches/soc-2010-leifandersen/tests/pyunit/ops/physics/particle_image.py	2010-06-18 19:50:40 UTC (rev 29549)
@@ -10,11 +10,37 @@
 
 
     def test_hair_generation(self):
-        pass
+        good = Image.open("cube_hair.png")
+        test = Image.open("cube_hair0001.png")
+        good_red = good_green = good_blue = test_red = test_green = test_blue = 0
 
+#       Much faster, should this be used instead?  Also, perhaps maping the pixel sums into sections
+#       might work.  Also, this doesn't really keep track of 
+#        good_sum = 0
+#        test_sum = 0
+#        for i in good.histogram():
+#            good_sum+=i
+#        for i in test.histogram():
+#            test_sum+=i
+        self.assertEquals(good.size, test.size)
+        for i in range(0, good.size[0]):
+            for j in range(0, good.size[1]):
+                good_red+=good.getpixel((i,j))[0]
+                good_green+=good.getpixel((i,j))[1]
+                good_blue+=good.getpixel((i,j))[2]
+                test_red+=test.getpixel((i,j))[0]
+                test_green+=test.getpixel((i,j))[1]
+                test_blue+=test.getpixel((i,j))[2]
+
+        self.assertEquals(good_red, test_red)
+        self.assertEquals(good_green, test_green)
+        self.assertEquals(good_blue, test_blue)
+
+
     def test_hair_ren_as_object(self):
         pass
 
+
     def test_hair_ren_as_group(self):
         pass
 

Added: branches/soc-2010-leifandersen/tests/pyunit/ops/physics/runtests.cmake
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/ops/physics/runtests.cmake	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/pyunit/ops/physics/runtests.cmake	2010-06-18 19:50:40 UTC (rev 29549)
@@ -0,0 +1,10 @@
+#set(Blender_BUILD_DIR /home/leif/blender-svn/blender-build)
+
+macro(EXEC_CHECK CMD)
+    execute_process(COMMAND ${CMD} RESULT_VARIABLE CMD_RESULT)
+    if(CMD_RESULT)
+        message(FATAL_ERROR "Error running ${CMD}")
+    endif()
+endmacro()
+exec_check(${Blender_BUILD_DIR}/bin/blender -b ${Blender_BUILD_DIR}/tests/pyunit/ops/physics/cube_hair.blend -o ${Blender_BUILD_DIR}/tests/pyunit/ops/physics/cube_hair -F PNG -x 1 -f 1)
+exec_check(python ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/particle_image.py)





More information about the Bf-blender-cvs mailing list