[Bf-blender-cvs] [64f5afdb89] master: [Cycles/MSVC/Testing] Fix broken test code.

lazydodo noreply at git.blender.org
Wed Jan 25 17:37:24 CET 2017


Commit: 64f5afdb89bbf3831e97d76a178acee1d9524452
Author: lazydodo
Date:   Wed Jan 25 09:36:41 2017 -0700
Branches: master
https://developer.blender.org/rB64f5afdb89bbf3831e97d76a178acee1d9524452

[Cycles/MSVC/Testing] Fix broken test code.

Currently the tests don't run on windows for the following reasons

1) render_graph_finalize has an linking issue due missing a bunch of libraries (not sure why this is not an issue for linux)
2) This one is more interesting, in test/python/cmakelists.txt ${TEST_BLENDER_EXE_BARE} and ${TEST_BLENDER_EXE} are flat out wrong, but for some reason this doesn't matter for most tests, cause ctest will actually go out and look for the executable and fix the path for you *BUT* only for the command, if you use them in any of the parameters it'll happily pass on the wrong path.
3) on linux you can just run a .py file, windows is not as awesome and needs to be told to run it with pyton.
4) had to use the NAME/COMMAND long form of add_test otherwise $<TARGET_FILE:blender> doesn't get expanded, why? beats me.
5) missing idiff.exe for msvc2015/x64 in the libs folder.

This patch addresses 1-4 , but given I have no working Linux build environment, I'm unsure if it'll break anything there

5 has been fixed in rBL61751

Reviewers: juicyfruit, brecht, sergey

Reviewed By: sergey

Subscribers: Blendify

Tags: #cycles, #automated_testing

Differential Revision: https://developer.blender.org/D2367

===================================================================

M	build_files/cmake/Modules/GTestTesting.cmake
M	build_files/cmake/macros.cmake
M	build_files/cmake/platform/platform_win32_msvc.cmake
M	intern/cycles/test/CMakeLists.txt
M	make.bat
M	tests/gtests/CMakeLists.txt
M	tests/gtests/blenlib/BLI_string_test.cc
M	tests/gtests/testing/CMakeLists.txt
M	tests/python/CMakeLists.txt

===================================================================

diff --git a/build_files/cmake/Modules/GTestTesting.cmake b/build_files/cmake/Modules/GTestTesting.cmake
index 96c06ef8eb..0732e10133 100644
--- a/build_files/cmake/Modules/GTestTesting.cmake
+++ b/build_files/cmake/Modules/GTestTesting.cmake
@@ -45,7 +45,7 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
 		                      RUNTIME_OUTPUT_DIRECTORY_DEBUG   "${TESTS_OUTPUT_DIR}"
 		                      INCLUDE_DIRECTORIES              "${TEST_INC}")
 		if(${DO_ADD_TEST})
-			add_test(${NAME}_test ${TESTS_OUTPUT_DIR}/${NAME}_test)
+			add_test(NAME ${NAME}_test COMMAND ${TESTS_OUTPUT_DIR}/${NAME}_test WORKING_DIRECTORY $<TARGET_FILE_DIR:blender>)
 		endif()
 	endif()
 endmacro()
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 2e3a190706..09428953a4 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -416,14 +416,7 @@ function(setup_liblinks
 		target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
 	endif()
 	if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
-		if(WIN32 AND NOT UNIX)
-			file_list_suffix(OPENSUBDIV_LIBRARIES_DEBUG "${OPENSUBDIV_LIBRARIES}" "_d")
-			target_link_libraries_debug(${target} "${OPENSUBDIV_LIBRARIES_DEBUG}")
-			target_link_libraries_optimized(${target} "${OPENSUBDIV_LIBRARIES}")
-			unset(OPENSUBDIV_LIBRARIES_DEBUG)
-		else()
 			target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
-		endif()
 	endif()
 	if(WITH_OPENVDB)
 		target_link_libraries(${target} ${OPENVDB_LIBRARIES} ${TBB_LIBRARIES})
diff --git a/build_files/cmake/platform/platform_win32_msvc.cmake b/build_files/cmake/platform/platform_win32_msvc.cmake
index 3b50351a13..1a266df779 100644
--- a/build_files/cmake/platform/platform_win32_msvc.cmake
+++ b/build_files/cmake/platform/platform_win32_msvc.cmake
@@ -446,10 +446,14 @@ if(WITH_MOD_CLOTH_ELTOPO)
 endif()
 
 if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
-	set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
-	set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
-	set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBPATH}/osdCPU.lib ${OPENSUBDIV_LIBPATH}/osdGPU.lib)
-	find_package(OpenSubdiv)
+    set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
+    set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
+    set(OPENSUBDIV_LIBRARIES    optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib 
+                                optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib
+                                debug ${OPENSUBDIV_LIBPATH}/osdCPU_d.lib 
+                                debug ${OPENSUBDIV_LIBPATH}/osdGPU_d.lib
+                                )
+    windows_find_package(OpenSubdiv)
 endif()
 
 if(WITH_SDL)
diff --git a/intern/cycles/test/CMakeLists.txt b/intern/cycles/test/CMakeLists.txt
index 9af777fb9d..80564c33be 100644
--- a/intern/cycles/test/CMakeLists.txt
+++ b/intern/cycles/test/CMakeLists.txt
@@ -54,12 +54,23 @@ if(WITH_CYCLES_OPENSUBDIV)
 endif()
 list(APPEND ALL_CYCLES_LIBRARIES
 	${BOOST_LIBRARIES}
+	${PNG_LIBRARIES}
+	${JPEG_LIBRARIES}
+	${ZLIB_LIBRARIES}
+	${TIFF_LIBRARY}
+	${OPENIMAGEIO_LIBRARIES}
+	${OPENEXR_LIBRARIES}
 )
 
 include_directories(${INC})
 
-link_directories(${BOOST_LIBPATH})
-link_directories(${OPENIMAGEIO_LIBPATH})
+link_directories(${OPENIMAGEIO_LIBPATH}
+                 ${BOOST_LIBPATH}
+                 ${PNG_LIBPATH}
+                 ${JPEG_LIBPATH}
+                 ${ZLIB_LIBPATH}
+                 ${TIFF_LIBPATH}
+                 ${OPENEXR_LIBPATH})
 
 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
diff --git a/make.bat b/make.bat
index c73101d143..337a551765 100644
--- a/make.bat
+++ b/make.bat
@@ -22,7 +22,7 @@ set MUST_CLEAN=
 set NOBUILD=
 set TARGET=
 set WINDOWS_ARCH=
-
+set TESTS_CMAKE_ARGS=
 :argv_loop
 if NOT "%1" == "" (
 
@@ -35,6 +35,8 @@ if NOT "%1" == "" (
 	if "%1" == "debug" (
 		set BUILD_TYPE=Debug
 	REM Build Configurations
+	) else if "%1" == "with_tests" (
+		set TESTS_CMAKE_ARGS=-DWITH_GTESTS=On
 	) else if "%1" == "full" (
 		set TARGET=Full
 		set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
@@ -204,7 +206,7 @@ if "%TARGET%"=="" (
 	goto HELP
 )
 
-set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%"
+set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%" %TESTS_CMAKE_ARGS%
 if NOT EXIST %BUILD_DIR%\nul (
 	mkdir %BUILD_DIR%
 )
@@ -284,6 +286,7 @@ goto EOF
 		echo - showhash ^(Show git hashes of source tree^)
 		echo.
 		echo Configuration options
+		echo - with_tests ^(enable building unit tests^)
 		echo - debug ^(Build an unoptimized debuggable build^)
 		echo - packagename [newname] ^(override default cpack package name^)
 		echo - x86 ^(override host autodetect and build 32 bit code^)
diff --git a/tests/gtests/CMakeLists.txt b/tests/gtests/CMakeLists.txt
index a3860ce3e6..1d363f3111 100644
--- a/tests/gtests/CMakeLists.txt
+++ b/tests/gtests/CMakeLists.txt
@@ -4,6 +4,9 @@ if(WITH_GTESTS)
 
 	Include(GTestTesting)
 
+	add_definitions(${GFLAGS_DEFINES})
+	add_definitions(${GLOG_DEFINES})
+
 	# Otherwise we get warnings here that we cant fix in external projects
 	remove_strict_flags()
 
diff --git a/tests/gtests/blenlib/BLI_string_test.cc b/tests/gtests/blenlib/BLI_string_test.cc
index 17a4b5e82b..08f2a745bd 100644
--- a/tests/gtests/blenlib/BLI_string_test.cc
+++ b/tests/gtests/blenlib/BLI_string_test.cc
@@ -374,7 +374,7 @@ TEST(string, StrFormatIntGrouped)
 	const int word_num = BLI_string_find_split_words( \
 	        word_str_src, word_str_src_len, ' ', word_info, word_cmp_size_input); \
 	EXPECT_EQ(word_num, word_cmp_size - 1); \
-	EXPECT_EQ_ARRAY_ND(word_cmp, word_info, word_cmp_size, 2); \
+	EXPECT_EQ_ARRAY_ND<const int[2]>(word_cmp, word_info, word_cmp_size, 2); \
 } ((void)0)
 
 #define STRING_FIND_SPLIT_WORDS(word_str_src, ...) \
diff --git a/tests/gtests/testing/CMakeLists.txt b/tests/gtests/testing/CMakeLists.txt
index 1eb60e7f3b..796f975ea6 100644
--- a/tests/gtests/testing/CMakeLists.txt
+++ b/tests/gtests/testing/CMakeLists.txt
@@ -47,7 +47,4 @@ set(SRC
 	testing.h
 )
 
-add_definitions(${GFLAGS_DEFINES})
-add_definitions(${GLOG_DEFINES})
-
 blender_add_lib(bf_testing_main "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index a29b612e0e..4b5666e9b5 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -399,24 +399,28 @@ endif()
 
 if(WITH_CYCLES)
 	if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/cycles/ctests/shader")
-		add_test(cycles_reports_test
-			${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
-			-blender "${TEST_BLENDER_EXE_BARE}"
-			-testdir "${TEST_SRC_DIR}/cycles/ctests/reports"
-			-idiff "${OPENIMAGEIO_IDIFF}"
-		)
-		add_test(cycles_render_test
-			${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
-			-blender "${TEST_BLENDER_EXE_BARE}"
-			-testdir "${TEST_SRC_DIR}/cycles/ctests/render"
-			-idiff "${OPENIMAGEIO_IDIFF}"
-		)
-		add_test(cycles_shaders_test
-			${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
-			-blender "${TEST_BLENDER_EXE_BARE}"
-			-testdir "${TEST_SRC_DIR}/cycles/ctests/shader"
-			-idiff "${OPENIMAGEIO_IDIFF}"
-		)
+		macro(add_cycles_render_test subject)
+			if(MSVC)
+				add_test(NAME cycles_${subject}_test
+					COMMAND
+						"$<TARGET_FILE_DIR:blender>/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>"
+						${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
+					-blender "$<TARGET_FILE:blender>"
+					-testdir "${TEST_SRC_DIR}/cycles/ctests/${subject}"
+					-idiff "${OPENIMAGEIO_IDIFF}"
+				)
+			else()
+				add_test(cycles_${subject}_test
+					 ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
+					-blender "${TEST_BLENDER_EXE_BARE}"
+					-testdir "${TEST_SRC_DIR}/cycles/ctests/${subject}"
+					-idiff "${OPENIMAGEIO_IDIFF}"
+				)
+			endif()
+		endmacro()	
+		add_cycles_render_test(reports)
+		add_cycles_render_test(render)
+		add_cycles_render_test(shader)
 	else()
 		MESSAGE(STATUS "Disabling Cycles tests because tests folder does not exist")
 	endif()




More information about the Bf-blender-cvs mailing list