From 835b9fbdc933878a744cd6ba1c77942610f4fe06 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sat, 3 Feb 2018 16:13:22 +0000 Subject: Improve stability of crypto_memcmp test. Also reduce number of people in conference to 5, because on Circle CI the test times out trying to connect more than 6 or 7 people. The persistent conferences PR will improve this so we can set it much higher then. --- CMakeLists.txt | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 542f151d..8cd5bae6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -429,7 +429,49 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox) ################################################################################ # -# :: Automated regression tests +# :: Unit tests: no networking, just pure function calls. +# +################################################################################ + +# Compile the GTest library. +# +if(EXISTS "/usr/src/gtest/src/gtest-all.cc") + add_library(gtest + /usr/src/gtest/src/gtest-all.cc + /usr/src/gtest/src/gtest_main.cc) + target_include_directories(gtest PRIVATE /usr/src/gtest) + check_cxx_compiler_flag("-w" HAVE_CXX_W QUIET) + check_cxx_compiler_flag("-Wno-global-constructors" HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS QUIET) + check_cxx_compiler_flag("-Wno-zero-as-null-pointer-constant" HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT QUIET) + if(HAVE_CXX_W) + set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w") + endif() + set(HAVE_GTEST TRUE) +endif() + +function(unit_test subdir target) + if(HAVE_GTEST) + add_executable(unit_${target}_test ${subdir}/${target}_test.cpp) + target_link_modules(unit_${target}_test ${toxcore_SUBLIBS} gtest) + set(gtest_CFLAGS "") + if(HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS) + set(gtest_CFLAGS "${gtest_CFLAGS} -Wno-global-constructors") + endif() + if(HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT) + set(gtest_CFLAGS "${gtest_CFLAGS} -Wno-zero-as-null-pointer-constant") + endif() + set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${gtest_CFLAGS}") + add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test) + endif() +endfunction() + +# The actual unit tests follow. +# +unit_test(toxcore crypto_core) + +################################################################################ +# +# :: Automated regression tests: create a tox network and run integration tests # ################################################################################ -- cgit v1.2.3