Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build_files/cmake/macros.cmake47
-rw-r--r--intern/cycles/test/CMakeLists.txt33
-rw-r--r--intern/cycles/test/util_avxf_avx2_test.cpp2
-rw-r--r--intern/cycles/test/util_avxf_avx_test.cpp2
-rw-r--r--intern/cycles/test/util_avxf_test.h53
-rw-r--r--intern/ffmpeg/CMakeLists.txt2
-rw-r--r--intern/guardedalloc/CMakeLists.txt2
-rw-r--r--source/blender/blenlib/CMakeLists.txt3
8 files changed, 96 insertions, 48 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 268daa4aae3..1e3863ac567 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -375,9 +375,8 @@ function(blender_add_lib
set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
endfunction()
-# blender_add_test_lib() is used to define a test library. It is intended to be
-# called in tandem with blender_add_lib(). The test library will be linked into
-# the bf_gtest_runner_test executable (see tests/gtests/CMakeLists.txt).
+# Add tests for a Blender library, to be called in tandem with blender_add_lib().
+# The tests will be part of the blender_test executable (see tests/gtests/runner).
function(blender_add_test_lib
name
sources
@@ -411,6 +410,48 @@ function(blender_add_test_lib
set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name})
endfunction()
+
+# Add tests for a Blender library, to be called in tandem with blender_add_lib().
+# Test will be compiled into a ${name}_test executable.
+#
+# To be used for smaller isolated libraries, that do not have many dependencies.
+# For libraries that do drag in many other Blender libraries and would create a
+# very large executable, blender_add_test_lib() should be used instead.
+function(blender_add_test_executable
+ name
+ sources
+ includes
+ includes_sys
+ library_deps
+ )
+
+ add_cc_flags_custom_test(${name} PARENT_SCOPE)
+
+ ## Otherwise external projects will produce warnings that we cannot fix.
+ remove_strict_flags()
+
+ include_directories(${includes})
+ include_directories(${includes_sys})
+ setup_libdirs()
+
+ BLENDER_SRC_GTEST_EX(
+ NAME ${name}
+ SRC "${sources}"
+ EXTRA_LIBS "${library_deps}"
+ SKIP_ADD_TEST
+ )
+
+ include(GTest)
+ set(_GOOGLETEST_DISCOVER_TESTS_SCRIPT
+ ${CMAKE_SOURCE_DIR}/build_files/cmake/Modules/GTestAddTests.cmake
+ )
+
+ gtest_discover_tests(${name}_test
+ DISCOVERY_MODE PRE_TEST
+ WORKING_DIRECTORY "${TEST_INSTALL_DIR}"
+ )
+endfunction()
+
# Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build.
function(setup_heavy_lib_pool)
if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
diff --git a/intern/cycles/test/CMakeLists.txt b/intern/cycles/test/CMakeLists.txt
index 1dc3d44dead..7d8f5916fef 100644
--- a/intern/cycles/test/CMakeLists.txt
+++ b/intern/cycles/test/CMakeLists.txt
@@ -19,12 +19,6 @@ if(WITH_GTESTS)
remove_strict_flags()
endif()
-macro(CYCLES_TEST SRC EXTRA_LIBS)
- if(WITH_GTESTS)
- BLENDER_SRC_GTEST("cycles_${SRC}" "${SRC}_test.cpp" "${EXTRA_LIBS}")
- endif()
-endmacro()
-
set(INC
.
..
@@ -50,15 +44,22 @@ include_directories(${INC})
cycles_link_directories()
-CYCLES_TEST(render_graph_finalize "${ALL_CYCLES_LIBRARIES};bf_intern_numaapi")
-cycles_target_link_libraries(cycles_render_graph_finalize_test)
-CYCLES_TEST(util_aligned_malloc "cycles_util")
-CYCLES_TEST(util_path "cycles_util;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
-CYCLES_TEST(util_string "cycles_util;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
-CYCLES_TEST(util_task "cycles_util;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES};bf_intern_numaapi")
-CYCLES_TEST(util_time "cycles_util;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
+set(SRC
+ render_graph_finalize_test.cpp
+ util_aligned_malloc_test.cpp
+ util_path_test.cpp
+ util_string_test.cpp
+ util_task_test.cpp
+ util_time_test.cpp
+ util_avxf_avx_test.cpp
+ util_avxf_avx2_test.cpp
+ util_transform_test.cpp
+)
+
set_source_files_properties(util_avxf_avx_test.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX_KERNEL_FLAGS}")
-CYCLES_TEST(util_avxf_avx "cycles_util;bf_intern_numaapi;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
set_source_files_properties(util_avxf_avx2_test.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
-CYCLES_TEST(util_avxf_avx2 "cycles_util;bf_intern_numaapi;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
-CYCLES_TEST(util_transform "cycles_util;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
+
+if(WITH_GTESTS)
+ BLENDER_SRC_GTEST(cycles "${SRC}" "${ALL_CYCLES_LIBRARIES}")
+ cycles_target_link_libraries(cycles_test)
+endif()
diff --git a/intern/cycles/test/util_avxf_avx2_test.cpp b/intern/cycles/test/util_avxf_avx2_test.cpp
index 9b466ddd3a0..c5365a81a51 100644
--- a/intern/cycles/test/util_avxf_avx2_test.cpp
+++ b/intern/cycles/test/util_avxf_avx2_test.cpp
@@ -16,6 +16,8 @@
#define __KERNEL_AVX2__
#define __KERNEL_CPU__
+#define TEST_CATEGORY_NAME util_avx2
+
#if defined(i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
# include "util_avxf_test.h"
#endif
diff --git a/intern/cycles/test/util_avxf_avx_test.cpp b/intern/cycles/test/util_avxf_avx_test.cpp
index cea67649b80..dbac20c69b3 100644
--- a/intern/cycles/test/util_avxf_avx_test.cpp
+++ b/intern/cycles/test/util_avxf_avx_test.cpp
@@ -16,6 +16,8 @@
#define __KERNEL_AVX__
#define __KERNEL_CPU__
+#define TEST_CATEGORY_NAME util_avx
+
#if defined(i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
# include "util_avxf_test.h"
#endif
diff --git a/intern/cycles/test/util_avxf_test.h b/intern/cycles/test/util_avxf_test.h
index d93563fdb3f..64825200c9e 100644
--- a/intern/cycles/test/util_avxf_test.h
+++ b/intern/cycles/test/util_avxf_test.h
@@ -20,7 +20,7 @@
CCL_NAMESPACE_BEGIN
-bool validate_cpu_capabilities()
+static bool validate_cpu_capabilities()
{
#ifdef __KERNEL_AVX2__
@@ -61,21 +61,22 @@ bool validate_cpu_capabilities()
for (size_t i = 0; i < a.size; i++) \
EXPECT_FLOAT_EQ(c[i], a[i] op b);
-const avxf avxf_a(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f);
-const avxf avxf_b(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f);
-const avxf avxf_c(1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f);
-const float float_b = 1.5f;
-
-TEST(util_avx, avxf_add_vv){basic_test_vv(avxf_a, avxf_b, +)} TEST(util_avx, avxf_sub_vv){
- basic_test_vv(avxf_a, avxf_b, -)} TEST(util_avx, avxf_mul_vv){
- basic_test_vv(avxf_a, avxf_b, *)} TEST(util_avx, avxf_div_vv){
- basic_test_vv(avxf_a, avxf_b, /)} TEST(util_avx, avxf_add_vf){
- basic_test_vf(avxf_a, float_b, +)} TEST(util_avx, avxf_sub_vf){
- basic_test_vf(avxf_a, float_b, -)} TEST(util_avx, avxf_mul_vf){
- basic_test_vf(avxf_a, float_b, *)} TEST(util_avx,
+static const avxf avxf_a(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f);
+static const avxf avxf_b(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f);
+static const avxf avxf_c(1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f);
+static const float float_b = 1.5f;
+
+TEST(TEST_CATEGORY_NAME, avxf_add_vv){basic_test_vv(avxf_a, avxf_b, +)} TEST(TEST_CATEGORY_NAME,
+ avxf_sub_vv){
+ basic_test_vv(avxf_a, avxf_b, -)} TEST(TEST_CATEGORY_NAME, avxf_mul_vv){
+ basic_test_vv(avxf_a, avxf_b, *)} TEST(TEST_CATEGORY_NAME, avxf_div_vv){
+ basic_test_vv(avxf_a, avxf_b, /)} TEST(TEST_CATEGORY_NAME, avxf_add_vf){
+ basic_test_vf(avxf_a, float_b, +)} TEST(TEST_CATEGORY_NAME, avxf_sub_vf){
+ basic_test_vf(avxf_a, float_b, -)} TEST(TEST_CATEGORY_NAME, avxf_mul_vf){
+ basic_test_vf(avxf_a, float_b, *)} TEST(TEST_CATEGORY_NAME,
avxf_div_vf){basic_test_vf(avxf_a, float_b, /)}
-TEST(util_avx, avxf_ctor)
+TEST(TEST_CATEGORY_NAME, avxf_ctor)
{
VALIDATECPU
compare_vector_scalar(avxf(7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.0f),
@@ -88,28 +89,28 @@ TEST(util_avx, avxf_ctor)
avxf(0.0f, 3.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f));
}
-TEST(util_avx, avxf_sqrt)
+TEST(TEST_CATEGORY_NAME, avxf_sqrt)
{
VALIDATECPU
compare_vector_vector(mm256_sqrt(avxf(1.0f, 4.0f, 9.0f, 16.0f, 25.0f, 36.0f, 49.0f, 64.0f)),
avxf(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f));
}
-TEST(util_avx, avxf_min_max)
+TEST(TEST_CATEGORY_NAME, avxf_min_max)
{
VALIDATECPU
compare_vector_vector(min(avxf_a, avxf_b), avxf_a);
compare_vector_vector(max(avxf_a, avxf_b), avxf_b);
}
-TEST(util_avx, avxf_set_sign)
+TEST(TEST_CATEGORY_NAME, avxf_set_sign)
{
VALIDATECPU
avxf res = set_sign_bit<1, 0, 0, 0, 0, 0, 0, 0>(avxf_a);
compare_vector_vector(res, avxf(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, -0.8f));
}
-TEST(util_avx, avxf_msub)
+TEST(TEST_CATEGORY_NAME, avxf_msub)
{
VALIDATECPU
avxf res = msub(avxf_a, avxf_b, avxf_c);
@@ -124,7 +125,7 @@ TEST(util_avx, avxf_msub)
compare_vector_vector(res, exp);
}
-TEST(util_avx, avxf_madd)
+TEST(TEST_CATEGORY_NAME, avxf_madd)
{
VALIDATECPU
avxf res = madd(avxf_a, avxf_b, avxf_c);
@@ -139,7 +140,7 @@ TEST(util_avx, avxf_madd)
compare_vector_vector(res, exp);
}
-TEST(util_avx, avxf_nmadd)
+TEST(TEST_CATEGORY_NAME, avxf_nmadd)
{
VALIDATECPU
avxf res = nmadd(avxf_a, avxf_b, avxf_c);
@@ -154,7 +155,7 @@ TEST(util_avx, avxf_nmadd)
compare_vector_vector(res, exp);
}
-TEST(util_avx, avxf_compare)
+TEST(TEST_CATEGORY_NAME, avxf_compare)
{
VALIDATECPU
avxf a(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f);
@@ -173,28 +174,28 @@ TEST(util_avx, avxf_compare)
compare_vector_vector(res, exp);
}
-TEST(util_avx, avxf_permute)
+TEST(TEST_CATEGORY_NAME, avxf_permute)
{
VALIDATECPU
avxf res = permute<3, 0, 1, 7, 6, 5, 2, 4>(avxf_b);
compare_vector_vector(res, avxf(4.0f, 6.0f, 3.0f, 2.0f, 1.0f, 7.0f, 8.0f, 5.0f));
}
-TEST(util_avx, avxf_blend)
+TEST(TEST_CATEGORY_NAME, avxf_blend)
{
VALIDATECPU
avxf res = blend<0, 0, 1, 0, 1, 0, 1, 0>(avxf_a, avxf_b);
compare_vector_vector(res, avxf(0.1f, 0.2f, 3.0f, 0.4f, 5.0f, 0.6f, 7.0f, 0.8f));
}
-TEST(util_avx, avxf_shuffle)
+TEST(TEST_CATEGORY_NAME, avxf_shuffle)
{
VALIDATECPU
avxf res = shuffle<0, 1, 2, 3, 1, 3, 2, 0>(avxf_a);
compare_vector_vector(res, avxf(0.4f, 0.2f, 0.1f, 0.3f, 0.5f, 0.6f, 0.7f, 0.8f));
}
-TEST(util_avx, avxf_cross)
+TEST(TEST_CATEGORY_NAME, avxf_cross)
{
VALIDATECPU
avxf res = cross(avxf_b, avxf_c);
@@ -210,7 +211,7 @@ TEST(util_avx, avxf_cross)
0.000002000f);
}
-TEST(util_avx, avxf_dot3)
+TEST(TEST_CATEGORY_NAME, avxf_dot3)
{
VALIDATECPU
float den, den2;
diff --git a/intern/ffmpeg/CMakeLists.txt b/intern/ffmpeg/CMakeLists.txt
index e141da9cbca..64a26230e33 100644
--- a/intern/ffmpeg/CMakeLists.txt
+++ b/intern/ffmpeg/CMakeLists.txt
@@ -38,5 +38,5 @@ if(WITH_GTESTS)
set(TEST_LIB ${TEST_LIB} ${OPENJPEG_LIBRARIES})
endif()
include(GTestTesting)
- blender_add_test_lib(bf_intern_ffmpeg_tests "${TEST_SRC}" "${TEST_INC}" "${TEST_INC_SYS}" "${TEST_LIB}")
+ blender_add_test_executable(ffmpeg "${TEST_SRC}" "${TEST_INC}" "${TEST_INC_SYS}" "${TEST_LIB}")
endif()
diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt
index ccc1500c014..0d46e81cd87 100644
--- a/intern/guardedalloc/CMakeLists.txt
+++ b/intern/guardedalloc/CMakeLists.txt
@@ -92,5 +92,5 @@ if(WITH_GTESTS)
bf_blenlib
)
include(GTestTesting)
- blender_add_test_lib(bf_intern_guardedalloc_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+ blender_add_test_executable(guardedalloc "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
endif()
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index e01459ac80e..b8de1e41d78 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -304,6 +304,7 @@ set(LIB
extern_wcwidth
${FREETYPE_LIBRARY}
+ ${ZLIB_LIBRARIES}
)
if(WITH_MEM_VALGRIND)
@@ -431,7 +432,7 @@ if(WITH_GTESTS)
bf_blenlib
)
include(GTestTesting)
- blender_add_test_lib(bf_blenlib_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+ blender_add_test_executable(blenlib "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
add_subdirectory(tests/performance)
endif()