diff --git a/cmake/modules/TestSuite.cmake b/cmake/modules/TestSuite.cmake --- a/cmake/modules/TestSuite.cmake +++ b/cmake/modules/TestSuite.cmake @@ -39,6 +39,10 @@ set(${TARGET} "check-${SUITE}") endmacro() +macro(get_pool_from_suite SUITE POOL) + set(${POOL} "${SUITE}-pool") +endmacro() + include(Coverage) function(create_test_suite_with_parent_targets NAME) @@ -62,6 +66,14 @@ create_test_suite_with_parent_targets(${NAME} check-all check-extended) endmacro() +# After this call, all the tests added to the suite will also be added to the +# pool. Works only with the Ninja generators. +function(test_suite_create_pool SUITE JOBS) + # Create a pool for the test suite + get_pool_from_suite(${SUITE} POOL) + set_property(GLOBAL APPEND PROPERTY JOB_POOLS ${POOL}=${JOBS}) +endfunction() + set(TEST_RUNNER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/../templates/TestRunner.cmake.in") function(add_test_runner SUITE NAME EXECUTABLE) cmake_parse_arguments(ARG "JUNIT" "" "" ${ARGN}) @@ -69,6 +81,14 @@ get_target_from_suite(${SUITE} SUITE_TARGET) set(TARGET "${SUITE_TARGET}-${NAME}") + # If there is a pool associated to the test suite, then add the test to the + # pool. + get_property(JOB_POOLS GLOBAL PROPERTY JOB_POOLS) + get_pool_from_suite(${SUITE} POOL) + if(JOB_POOLS MATCHES ${POOL}) + set(JOB_POOL_ARG JOB_POOL ${POOL}) + endif() + add_test_custom_target(${TARGET} TEST_COMMAND "${CMAKE_SOURCE_DIR}/cmake/utils/test_wrapper.sh" @@ -78,6 +98,7 @@ COMMENT "${SUITE}: testing ${NAME}" DEPENDS ${EXECUTABLE} VERBATIM + ${JOB_POOL_ARG} ) add_dependencies(${SUITE_TARGET} ${TARGET}) diff --git a/src/leveldb/CMakeLists.txt b/src/leveldb/CMakeLists.txt --- a/src/leveldb/CMakeLists.txt +++ b/src/leveldb/CMakeLists.txt @@ -179,6 +179,9 @@ if(LEVELDB_BUILD_TESTS) include(TestSuite) create_test_suite(leveldb) + # Create a single job pool for the test suite in order to make the tests run + # serially. + test_suite_create_pool(leveldb 1) add_library(leveldb_test_base EXCLUDE_FROM_ALL