From 3bcfd3f45f7b452df27b219f9f2e7cf9f5b601fd Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Fri, 24 Jun 2016 10:59:05 +0200 Subject: [PATCH] Build some tests --- .appveyor.yml | 5 +- .travis.yml | 12 ++-- CMakeLists.txt | 163 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 172 insertions(+), 8 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 0584bf6..61b3355 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -19,6 +19,5 @@ build_script: - cd c:\projects\tbb - cmake -G "%CMAKE_PLATFORM%" - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - set MSBuildOptions=/v:m /p:Configuration=%Configuration% /logger:%MSBuildLogger% - - msbuild %MSBuildOptions% tbb.sln - - ctest -C %Configuration% + - cmake --build . --config %Configuration% --target tests -- /v:m /logger:%MSBuildLogger% + - ctest -C %Configuration% --output-on-failure --timeout 500 diff --git a/.travis.yml b/.travis.yml index ae6ee22..54c2865 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,8 @@ matrix: compiler: gcc-4.8 script: - CXXFLAGS="-mno-rtm" cmake -DCMAKE_CXX_COMPILER=g++-4.8 . - - make -j 2 + - make -j2 + - make tests -j2 && ctest -j2 --output-on-failure --timeout 500 addons: apt: sources: @@ -20,12 +21,14 @@ matrix: compiler: clang script: - cmake . - - make -j 2 + - make -j2 + - make tests -j2 && ctest -j2 --output-on-failure --timeout 500 - os: linux compiler: x86_64-w64-mingw32-g++ script: - cmake -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_TOOLCHAIN_FILE=build/mingw_cross_toolchain.cmake -DGNU_HOST=x86_64-w64-mingw32 . - - make -j 2 + - make -j2 + - make tests -j2 addons: apt: packages: @@ -36,7 +39,8 @@ matrix: compiler: i686-w64-mingw32-g++ script: - cmake -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ -DCMAKE_TOOLCHAIN_FILE=build/mingw_cross_toolchain.cmake -DGNU_HOST=i686-w64-mingw32 . - - make -j 2 + - make -j2 + - make tests -j2 addons: apt: packages: diff --git a/CMakeLists.txt b/CMakeLists.txt index 49ca45e..b8a6db4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 2.8) -project(tbb CXX) +project (tbb CXX) include (CheckCXXCompilerFlag) @@ -20,6 +20,7 @@ option(TBB_BUILD_SHARED "Build TBB shared library" ON) option(TBB_BUILD_STATIC "Build TBB static library" ON) option(TBB_BUILD_TBBMALLOC "Build TBB malloc library" ON) option(TBB_BUILD_TBBMALLOC_PROXY "Build TBB malloc proxy library" ON) +option(TBB_BUILD_TESTS "Build TBB tests and enable testing infrastructure" ON) if(APPLE) set(CMAKE_MACOSX_RPATH ON) @@ -61,6 +62,9 @@ if (UNIX) set(CMAKE_CXX_FLAGS "-mrtm ${CMAKE_CXX_FLAGS}") elseif(WIN32) if (MSVC) + #pragma comment( linker, "/nodefaultlib:tbb_debug.lib" ) + set (CMAKE_DEBUG_POSTFIX "_debug") + cmake_minimum_required (VERSION 3.1) enable_language(ASM_MASM) set(CMAKE_CXX_FLAGS "/GS- /Zc:wchar_t /Zc:forScope /DUSE_WINTHREAD ${CMAKE_CXX_FLAGS}") @@ -247,3 +251,160 @@ else () endif() include_directories (${CMAKE_BINARY_DIR}) configure_file (build/version_string.ver.in version_string.ver @ONLY) + + +if (TBB_BUILD_TESTS) + enable_language (C) + enable_testing () + + find_library (LIBRT_LIBRARIES rt) + find_library (LIDL_LIBRARIES dl) + find_package (Threads) + find_package (OpenMP) + + add_custom_target (tests) + + macro (tbb_add_test testname) + add_executable (test_${testname} EXCLUDE_FROM_ALL src/test/test_${testname}.cpp) + add_dependencies (tests test_${testname}) + if (TBB_BUILD_SHARED) + target_link_libraries (test_${testname} tbb) + else () + target_link_libraries (test_${testname} tbb_static) + endif () + if (LIBRT_LIBRARIES) + target_link_libraries (test_${testname} ${LIBRT_LIBRARIES}) + endif () + if (LIDL_LIBRARIES) + target_link_libraries (test_${testname} ${LIDL_LIBRARIES}) + endif () + if (Threads_FOUND) + target_link_libraries (test_${testname} ${CMAKE_THREAD_LIBS_INIT}) + endif () + if (OPENMP_FOUND AND "${testname}" MATCHES "openmp") + set_target_properties (test_${testname} PROPERTIES COMPILE_FLAGS "${OpenMP_CXX_FLAGS}") + set_target_properties (test_${testname} PROPERTIES LINK_FLAGS "${OpenMP_CXX_FLAGS}") + endif() + if (MINGW) + target_link_libraries (test_${testname} psapi) + endif () + add_test (NAME ${testname} COMMAND test_${testname}) + endmacro () + + tbb_add_test (aggregator) + tbb_add_test (aligned_space) + tbb_add_test (assembly) + tbb_add_test (async_msg) + tbb_add_test (async_node) +# tbb_add_test (atomic) # msvc64/debug timeouts: Compile-time initialization fails for static tbb::atomic variables + tbb_add_test (blocked_range2d) + tbb_add_test (blocked_range3d) + tbb_add_test (blocked_range) + tbb_add_test (broadcast_node) + tbb_add_test (buffer_node) + tbb_add_test (cache_aligned_allocator) + tbb_add_test (cache_aligned_allocator_STL) + tbb_add_test (cilk_dynamic_load) + tbb_add_test (cilk_interop) + tbb_add_test (combinable) + tbb_add_test (composite_node) + tbb_add_test (concurrent_hash_map) + tbb_add_test (concurrent_lru_cache) +# tbb_add_test (concurrent_monitor) # too long + # tbb_add_test (concurrent_priority_queue) + tbb_add_test (concurrent_queue) + # tbb_add_test (concurrent_queue_whitebox) + tbb_add_test (concurrent_unordered_map) + # tbb_add_test (concurrent_unordered_set) + tbb_add_test (concurrent_vector) + tbb_add_test (continue_node) + tbb_add_test (critical_section) + tbb_add_test (dynamic_link) + # tbb_add_test (eh_algorithms) + tbb_add_test (eh_flow_graph) +# tbb_add_test (eh_tasks) + tbb_add_test (enumerable_thread_specific) + tbb_add_test (examples_common_utility) + # tbb_add_test (fast_random) + tbb_add_test (flow_graph) + tbb_add_test (flow_graph_whitebox) +# tbb_add_test (fp) # mingw: harness_fp.h:66, assertion !checkConsistency || (ctl.mxcsr & SSE_RND_MODE_MASK) >> 3 == (ctl.x87cw & FE_RND_MODE_MASK): failed +# tbb_add_test (function_node) # mingw:random timeout +# tbb_add_test (global_control) + # tbb_add_test (global_control_whitebox) + tbb_add_test (halt) + tbb_add_test (handle_perror) + # tbb_add_test (hw_concurrency) + tbb_add_test (indexer_node) + tbb_add_test (inits_loop) + tbb_add_test (intrusive_list) + tbb_add_test (ittnotify) +# tbb_add_test (join_node) #msvc/64: fatal error C1128: number of sections exceeded object file format limit: compile with /bigob + tbb_add_test (lambda) + tbb_add_test (limiter_node) + # tbb_add_test (malloc_atexit) + tbb_add_test (malloc_compliance) + tbb_add_test (malloc_init_shutdown) + # tbb_add_test (malloc_lib_unload) +# tbb_add_test (malloc_overload) + tbb_add_test (malloc_pools) + tbb_add_test (malloc_regression) + # tbb_add_test (malloc_used_by_lib) + # tbb_add_test (malloc_whitebox) + tbb_add_test (model_plugin) +# tbb_add_test (multifunction_node) # too long + tbb_add_test (mutex) + tbb_add_test (mutex_native_threads) + # tbb_add_test (opencl_node) + if (OPENMP_FOUND) + tbb_add_test (openmp) + endif () + tbb_add_test (overwrite_node) + # tbb_add_test (parallel_do) + tbb_add_test (parallel_for) + tbb_add_test (parallel_for_each) + tbb_add_test (parallel_for_vectorization) + tbb_add_test (parallel_invoke) + tbb_add_test (parallel_pipeline) + tbb_add_test (parallel_reduce) + tbb_add_test (parallel_scan) + tbb_add_test (parallel_sort) + tbb_add_test (parallel_while) +# tbb_add_test (partitioner_whitebox) # too long + tbb_add_test (pipeline) +# tbb_add_test (pipeline_with_tbf) # takes forever on appveyor + tbb_add_test (priority_queue_node) + tbb_add_test (queue_node) + tbb_add_test (reader_writer_lock) +# tbb_add_test (runtime_loader) # LINK : fatal error LNK1104: cannot open file 'tbbproxy.lib' [C:\projects\tbb\test_runtime_loader.vcxproj] + tbb_add_test (rwm_upgrade_downgrade) + # tbb_add_test (ScalableAllocator) + tbb_add_test (ScalableAllocator_STL) + tbb_add_test (semaphore) +# tbb_add_test (sequencer_node) # msvc: timeout + tbb_add_test (source_node) + tbb_add_test (split_node) + tbb_add_test (static_assert) + tbb_add_test (std_thread) + tbb_add_test (tagged_msg) +# tbb_add_test (task_arena) # LINK : fatal error LNK1104: cannot open file '__TBB_LIB_NAME.lib' [C:\projects\tbb\test_task_arena.vcxproj] + # tbb_add_test (task_assertions) + tbb_add_test (task_auto_init) + tbb_add_test (task) +# tbb_add_test (task_enqueue) # too long + tbb_add_test (task_group) + # tbb_add_test (task_leaks) +# tbb_add_test (task_priority) +# tbb_add_test (task_scheduler_init) # msvc: test_task_scheduler_init.cpp:68, assertion !test_mandatory_parallelism || Harness::CanReachConcurrencyLevel(threads): failed + tbb_add_test (task_scheduler_observer) + tbb_add_test (task_steal_limit) + tbb_add_test (tbb_condition_variable) + tbb_add_test (tbb_fork) + tbb_add_test (tbb_header) + tbb_add_test (tbb_thread) + # tbb_add_test (tbb_version) + tbb_add_test (tick_count) + tbb_add_test (tuple) + tbb_add_test (write_once_node) + tbb_add_test (yield) +endif ()