diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-02-22 17:07:18 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-02-22 17:07:18 +0300 |
commit | c6e4a81dfbef7ddbfc89725147940385e55a9dcb (patch) | |
tree | a2bd1b74bc5bf9bdc7d38de3fe888f0d5f6e2fc5 | |
parent | 3c043732d3f5eb09d4a6bb20248db65a2fe033e2 (diff) |
Blender 2.78c: Port all commits related on new Cycles regression tests
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | build_files/cmake/Modules/GTestTesting.cmake | 2 | ||||
-rw-r--r-- | build_files/cmake/macros.cmake | 7 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_win32_msvc.cmake | 12 | ||||
-rw-r--r-- | intern/cycles/test/CMakeLists.txt | 15 | ||||
-rw-r--r-- | make.bat | 7 | ||||
-rw-r--r-- | tests/gtests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_string_test.cc | 2 | ||||
-rw-r--r-- | tests/gtests/testing/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/python/CMakeLists.txt | 50 | ||||
-rwxr-xr-x | tests/python/cycles_render_tests.py | 146 |
11 files changed, 180 insertions, 68 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 578f913f8c7..8a48e6e9a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -445,6 +445,7 @@ option(WITH_BOOST "Enable features depending on boost" ON) # Unit testsing option(WITH_GTESTS "Enable GTest unit testing" OFF) +option(WITH_OPENGL_TESTS "Enable OpenGL related unit testing (Experimental)" OFF) # Documentation diff --git a/build_files/cmake/Modules/GTestTesting.cmake b/build_files/cmake/Modules/GTestTesting.cmake index 96c06ef8eb5..0732e10133c 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 5a67ac981a3..1aa440bff3d 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 ecdba59978e..79efe319508 100644 --- a/build_files/cmake/platform/platform_win32_msvc.cmake +++ b/build_files/cmake/platform/platform_win32_msvc.cmake @@ -444,10 +444,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 9af777fb9dd..80564c33be6 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}") @@ -17,7 +17,7 @@ set MUST_CLEAN= set NOBUILD= set TARGET= set WINDOWS_ARCH= - +set TESTS_CMAKE_ARGS= :argv_loop if NOT "%1" == "" ( @@ -30,6 +30,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% ^ @@ -183,7 +185,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% ) @@ -262,6 +264,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 a3860ce3e67..1d363f31119 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 17a4b5e82b9..08f2a745bdb 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 1eb60e7f3b5..796f975ea65 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 8487c6a2094..d9731a5dfaa 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -95,6 +95,11 @@ add_test(bevel ${TEST_BLENDER_EXE} --python-text run_tests ) +add_test(split_faces ${TEST_BLENDER_EXE} + ${TEST_SRC_DIR}/modeling/split_faces_test.blend + --python-text run_tests +) + # ------------------------------------------------------------------------------ # IO TESTS @@ -399,24 +404,33 @@ 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() + if(WITH_OPENGL_TESTS) + add_cycles_render_test(opengl) + endif() + add_cycles_render_test(image) + add_cycles_render_test(mblur) + 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() diff --git a/tests/python/cycles_render_tests.py b/tests/python/cycles_render_tests.py index fa4b3f2efdb..a030cc5e0de 100755 --- a/tests/python/cycles_render_tests.py +++ b/tests/python/cycles_render_tests.py @@ -6,24 +6,82 @@ import os import shutil import subprocess import sys +import time import tempfile +class COLORS_ANSI: + RED = '\033[00;31m' + GREEN = '\033[00;32m' + ENDC = '\033[0m' + + +class COLORS_DUMMY: + RED = '' + GREEN = '' + ENDC = '' + +COLORS = COLORS_DUMMY + + +def printMessage(type, status, message): + if type == 'SUCCESS': + print(COLORS.GREEN, end="") + elif type == 'FAILURE': + print(COLORS.RED, end="") + status_text = ... + if status == 'RUN': + status_text = " RUN " + elif status == 'OK': + status_text = " OK " + elif status == 'PASSED': + status_text = " PASSED " + elif status == 'FAILED': + status_text = " FAILED " + else: + status_text = status + print("[{}]" . format(status_text), end="") + print(COLORS.ENDC, end="") + print(" {}" . format(message)) + sys.stdout.flush() + + def render_file(filepath): - command = ( - BLENDER, - "--background", - "-noaudio", - "--factory-startup", - "--enable-autoexec", - filepath, - "-E", "CYCLES", - # Run with OSL enabled - # "--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True", - "-o", TEMP_FILE_MASK, - "-F", "PNG", - "-f", "1", + dirname = os.path.dirname(filepath) + basedir = os.path.dirname(dirname) + subject = os.path.basename(dirname) + if subject == 'opengl': + command = ( + BLENDER, + "--window-geometry", "0", "0", "1", "1", + "-noaudio", + "--factory-startup", + "--enable-autoexec", + filepath, + "-E", "CYCLES", + # Run with OSL enabled + # "--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True", + "-o", TEMP_FILE_MASK, + "-F", "PNG", + '--python', os.path.join(basedir, + "util", + "render_opengl.py") ) + else: + command = ( + BLENDER, + "--background", + "-noaudio", + "--factory-startup", + "--enable-autoexec", + filepath, + "-E", "CYCLES", + # Run with OSL enabled + # "--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True", + "-o", TEMP_FILE_MASK, + "-F", "PNG", + "-f", "1", + ) try: output = subprocess.check_output(command) if VERBOSE: @@ -84,16 +142,32 @@ def verify_output(filepath): def run_test(filepath): testname = test_get_name(filepath) spacer = "." * (32 - len(testname)) - print(testname, spacer, end="") - sys.stdout.flush() + printMessage('SUCCESS', 'RUN', testname) + time_start = time.time() error = render_file(filepath) + status = "FAIL" if not error: - if verify_output(filepath): - print("PASS") - else: + if not verify_output(filepath): error = "VERIFY" - if error: - print("FAIL", error) + time_end = time.time() + elapsed_ms = int((time_end - time_start) * 1000) + if not error: + printMessage('SUCCESS', 'OK', "{} ({} ms)" . + format(testname, elapsed_ms)) + else: + if error == "NO_CYCLES": + print("Can't perform tests because Cycles failed to load!") + return False + elif error == "NO_START": + print('Can not perform tests because blender fails to start.', + 'Make sure INSTALL target was run.') + return False + elif error == 'VERIFY': + print("Rendered result is different from reference image") + else: + print("Unknown error %r" % error) + printMessage('FAILURE', 'FAILED', "{} ({} ms)" . + format(testname, elapsed_ms)) return error @@ -106,30 +180,38 @@ def blend_list(path): def run_all_tests(dirpath): + passed_tests = [] failed_tests = [] all_files = list(blend_list(dirpath)) all_files.sort() + printMessage('SUCCESS', "==========", + "Running {} tests from 1 test case." . format(len(all_files))) + time_start = time.time() for filepath in all_files: error = run_test(filepath) + testname = test_get_name(filepath) if error: if error == "NO_CYCLES": - print("Can't perform tests because Cycles failed to load!") return False elif error == "NO_START": - print('Can not perform tests because blender fails to start.', - 'Make sure INSTALL target was run.') return False - elif error == 'VERIFY': - pass - else: - print("Unknown error %r" % error) - testname = test_get_name(filepath) failed_tests.append(testname) + else: + passed_tests.append(testname) + time_end = time.time() + elapsed_ms = int((time_end - time_start) * 1000) + print("") + printMessage('SUCCESS', "==========", + "{} tests from 1 test case ran. ({} ms total)" . + format(len(all_files), elapsed_ms)) + printMessage('SUCCESS', 'PASSED', "{} tests." . + format(len(passed_tests))) if failed_tests: + printMessage('FAILURE', 'FAILED', "{} tests, listed below:" . + format(len(failed_tests))) failed_tests.sort() - print("\n\nFAILED tests:") for test in failed_tests: - print(" ", test) + printMessage('FAILURE', "FAILED", "{}" . format(test)) return False return True @@ -146,10 +228,14 @@ def main(): parser = create_argparse() args = parser.parse_args() + global COLORS global BLENDER, ROOT, IDIFF global TEMP_FILE, TEMP_FILE_MASK, TEST_SCRIPT global VERBOSE + if os.environ.get("CYCLESTEST_COLOR") is not None: + COLORS = COLORS_ANSI + BLENDER = args.blender[0] ROOT = args.testdir[0] IDIFF = args.idiff[0] |