diff --git a/CMakeLists.txt b/CMakeLists.txt index a2866f9438..3b4a5852ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -368,6 +368,15 @@ if (BUILD_TESTS) include(CTest) enable_testing() message(STATUS "Unit tests are enabled") + + set (TEST_JOB_COUNT "" CACHE STRING "Override number of parallel jobs to use while running tests") + if (TEST_JOB_COUNT) + message(STATUS "Running tests with ${TEST_JOB_COUNT} jobs") + endif() + if (CMAKE_VERSION VERSION_LESS "3.29") + execute_process(COMMAND "nproc" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE TEST_JOB_COUNT) + endif() + set(TEST_JOB_FLAG "-j${TEST_JOB_COUNT}") endif() add_subdirectory(FEXHeaderUtils/) diff --git a/FEXCore/unittests/APITests/CMakeLists.txt b/FEXCore/unittests/APITests/CMakeLists.txt index 85f86cc76d..52ffd05098 100644 --- a/FEXCore/unittests/APITests/CMakeLists.txt +++ b/FEXCore/unittests/APITests/CMakeLists.txt @@ -10,12 +10,9 @@ foreach(TEST ${TESTS}) catch_discover_tests(FEXCore_Tests_${TEST_NAME} TEST_SUFFIX ".${TEST_NAME}.FEXCore_Tests") endforeach() -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( fexcore_apitests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*.FEXCore_Tests$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*.FEXCore_Tests$$") diff --git a/FEXCore/unittests/Emitter/CMakeLists.txt b/FEXCore/unittests/Emitter/CMakeLists.txt index 2937245568..408c4b5fb0 100644 --- a/FEXCore/unittests/Emitter/CMakeLists.txt +++ b/FEXCore/unittests/Emitter/CMakeLists.txt @@ -11,14 +11,11 @@ if (COMPILE_VIXL_DISASSEMBLER) catch_discover_tests(Emitter_${TEST_NAME} TEST_SUFFIX ".${TEST_NAME}.Emitter") endforeach() - execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) - string(STRIP ${CORES} CORES) - add_custom_target( emitter_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*.Emitter$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*.Emitter$$") else() message(AUTHOR_WARNING "Tests are enabled but vixl disassembler is not. Emitter tests won't be built.") endif() diff --git a/Source/Tools/LinuxEmulation/CMakeLists.txt b/Source/Tools/LinuxEmulation/CMakeLists.txt index 9ff006d6a1..3076a31586 100644 --- a/Source/Tools/LinuxEmulation/CMakeLists.txt +++ b/Source/Tools/LinuxEmulation/CMakeLists.txt @@ -162,11 +162,8 @@ foreach(Index RANGE 0 ${ARG_COUNT} 2) set_property(TEST ${TEST_NAME_ARCH}_aarch64 APPEND PROPERTY DEPENDS "${HEADER}") endforeach() -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( struct_verifier WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "Test_verify*") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "Test_verify*") diff --git a/unittests/32Bit_ASM/CMakeLists.txt b/unittests/32Bit_ASM/CMakeLists.txt index 77af112250..26366f1468 100644 --- a/unittests/32Bit_ASM/CMakeLists.txt +++ b/unittests/32Bit_ASM/CMakeLists.txt @@ -110,13 +110,10 @@ endforeach() add_custom_target(32bit_asm_files ALL DEPENDS "${ASM_DEPENDS}") -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( 32bit_asm_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL DEPENDS 32bit_asm_files DEPENDS "${CMAKE_BINARY_DIR}/Bin/TestHarnessRunner" - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*32Bit\.*.asm$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*32Bit\.*.asm$$") diff --git a/unittests/APITests/CMakeLists.txt b/unittests/APITests/CMakeLists.txt index 47cfbdd819..4a56cd5b30 100644 --- a/unittests/APITests/CMakeLists.txt +++ b/unittests/APITests/CMakeLists.txt @@ -14,14 +14,11 @@ foreach(API_TEST ${TESTS}) TEST_SUFFIX ".${API_TEST}.APITest") endforeach() -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( api_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*.APITest") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*.APITest") foreach(API_TEST ${TESTS}) add_dependencies(api_tests ${API_TEST}) diff --git a/unittests/ASM/CMakeLists.txt b/unittests/ASM/CMakeLists.txt index 056e500d6b..b78073e1c8 100644 --- a/unittests/ASM/CMakeLists.txt +++ b/unittests/ASM/CMakeLists.txt @@ -117,16 +117,13 @@ endforeach() add_custom_target(asm_files ALL DEPENDS "${ASM_DEPENDS}") -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( 64bit_asm_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL DEPENDS asm_files DEPENDS "${CMAKE_BINARY_DIR}/Bin/TestHarnessRunner" - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*64Bit\.*.asm$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*64Bit\.*.asm$$") add_custom_target( asm_tests @@ -135,4 +132,4 @@ add_custom_target( DEPENDS asm_files DEPENDS 32bit_asm_files DEPENDS "${CMAKE_BINARY_DIR}/Bin/TestHarnessRunner" - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*.asm$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*.asm$$") diff --git a/unittests/FEXLinuxTests/CMakeLists.txt b/unittests/FEXLinuxTests/CMakeLists.txt index 1986a7ba46..ecc041df24 100644 --- a/unittests/FEXLinuxTests/CMakeLists.txt +++ b/unittests/FEXLinuxTests/CMakeLists.txt @@ -97,15 +97,12 @@ if(TEST thunk_testlib.64.jit.flt) set_property(TEST "thunk_testlib.64.jit.flt" PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib") endif() -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - # Only emulated add_custom_target( fex_linux_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "30" "-j${CORES}" "-R" "\.*\.jit\.flt$$" + COMMAND "ctest" "--output-on-failure" "--timeout" "30" ${TEST_JOB_FLAG} "-R" "\.*\.jit\.flt$$" DEPENDS FEXLinuxTests FEXLinuxTests_32 FEXLoader ) @@ -114,7 +111,7 @@ add_custom_target( fex_linux_tests_host WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "30" "-j${CORES}" "-R" "\.*\.host\.flt$$" + COMMAND "ctest" "--output-on-failure" "--timeout" "30" ${TEST_JOB_FLAG} "-R" "\.*\.host\.flt$$" DEPENDS FEXLinuxTests FEXLinuxTests_32 ) @@ -123,6 +120,6 @@ add_custom_target( fex_linux_tests_all WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "30" "-j${CORES}" "-R" "\.*\.flt$$" + COMMAND "ctest" "--output-on-failure" "--timeout" "30" ${TEST_JOB_FLAG} "-R" "\.*\.flt$$" DEPENDS FEXLinuxTests FEXLinuxTests_32 FEXLoader ) diff --git a/unittests/InstructionCountCI/CMakeLists.txt b/unittests/InstructionCountCI/CMakeLists.txt index 6c7afd123c..666dd1efc4 100644 --- a/unittests/InstructionCountCI/CMakeLists.txt +++ b/unittests/InstructionCountCI/CMakeLists.txt @@ -49,18 +49,15 @@ endforeach() add_custom_target(instcountci_test_files ALL DEPENDS "${JSON_DEPENDS}") -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( instcountci_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL DEPENDS instcountci_test_files - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "InstCountCI/\.*.instcountci$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "InstCountCI/\.*.instcountci$$") add_custom_target( instcountci_update_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "InstCountCI/\.*new_numbers$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "InstCountCI/\.*new_numbers$$") diff --git a/unittests/POSIX/CMakeLists.txt b/unittests/POSIX/CMakeLists.txt index eb49924f91..eac0bc6da4 100644 --- a/unittests/POSIX/CMakeLists.txt +++ b/unittests/POSIX/CMakeLists.txt @@ -23,11 +23,8 @@ foreach(POSIX_TEST ${POSIX_TESTS}) endforeach() -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( posix_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*.posix") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*.posix") diff --git a/unittests/ThunkFunctionalTests/CMakeLists.txt b/unittests/ThunkFunctionalTests/CMakeLists.txt index 24d0047e09..8e10ea3eb3 100644 --- a/unittests/ThunkFunctionalTests/CMakeLists.txt +++ b/unittests/ThunkFunctionalTests/CMakeLists.txt @@ -32,26 +32,23 @@ endfunction() AddTest("/usr/bin/glxinfo" "GLThunks.json") AddTest("/usr/bin/vulkaninfo" "VulkanThunks.json") -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( thunk_functional_tests_nothunks WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "ThunkFunctionalTest-NoThunks-\.*" + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "ThunkFunctionalTest-NoThunks-\.*" DEPENDS "${FUNCTIONAL_DEPENDS}") add_custom_target( thunk_functional_tests_thunks WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "ThunkFunctionalTest-Thunks-\.*" + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "ThunkFunctionalTest-Thunks-\.*" DEPENDS "${FUNCTIONAL_DEPENDS}") add_custom_target( thunk_functional_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "ThunkFunctionalTest\.*" + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "ThunkFunctionalTest\.*" DEPENDS "${FUNCTIONAL_DEPENDS}") diff --git a/unittests/ThunkLibs/CMakeLists.txt b/unittests/ThunkLibs/CMakeLists.txt index 8618eaa662..77b17f32d5 100644 --- a/unittests/ThunkLibs/CMakeLists.txt +++ b/unittests/ThunkLibs/CMakeLists.txt @@ -4,12 +4,9 @@ target_link_libraries(thunkgentest PRIVATE fmt::fmt) target_link_libraries(thunkgentest PRIVATE thunkgenlib) catch_discover_tests(thunkgentest TEST_SUFFIX ".ThunkGen") -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( thunkgen_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*.ThunkGen") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*.ThunkGen") add_dependencies(thunkgen_tests thunkgentest) diff --git a/unittests/gcc-target-tests-32/CMakeLists.txt b/unittests/gcc-target-tests-32/CMakeLists.txt index 7ee2ec8b4a..f520c70037 100644 --- a/unittests/gcc-target-tests-32/CMakeLists.txt +++ b/unittests/gcc-target-tests-32/CMakeLists.txt @@ -23,11 +23,8 @@ foreach(TEST ${TESTS}) endforeach() -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( gcc_target_tests_32 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "20" "-j${CORES}" "-R" "\.*.gcc-target-32$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "20" ${TEST_JOB_FLAG} "-R" "\.*.gcc-target-32$$") diff --git a/unittests/gcc-target-tests-64/CMakeLists.txt b/unittests/gcc-target-tests-64/CMakeLists.txt index 76f26a24b0..bb49082fab 100644 --- a/unittests/gcc-target-tests-64/CMakeLists.txt +++ b/unittests/gcc-target-tests-64/CMakeLists.txt @@ -23,11 +23,8 @@ foreach(TEST ${TESTS}) endforeach() -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) - add_custom_target( gcc_target_tests_64 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL - COMMAND "ctest" "--output-on-failure" "--timeout" "20" "-j${CORES}" "-R" "\.*.gcc-target-64$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "20" ${TEST_JOB_FLAG} "-R" "\.*.gcc-target-64$$") diff --git a/unittests/gvisor-tests/CMakeLists.txt b/unittests/gvisor-tests/CMakeLists.txt index cd826b0872..af72a1cf16 100644 --- a/unittests/gvisor-tests/CMakeLists.txt +++ b/unittests/gvisor-tests/CMakeLists.txt @@ -23,8 +23,6 @@ foreach(TEST ${TESTS}) endforeach() -execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) -string(STRIP ${CORES} CORES) set(RM_DIR_COMMAND "rm $ENV{ROOTFS}/tmp 2> /dev/null || true") add_custom_target( @@ -33,4 +31,4 @@ add_custom_target( WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" USES_TERMINAL COMMAND "sh" "-c" "${RM_DIR_COMMAND}" - COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "\.*.gvisor$$") + COMMAND "ctest" "--output-on-failure" "--timeout" "302" ${TEST_JOB_FLAG} "-R" "\.*.gvisor$$")