Skip to content

Commit

Permalink
Merge pull request #3803 from pmatos/NinjaCore
Browse files Browse the repository at this point in the history
Use number of jobs as defined by TEST_JOB_COUNT
  • Loading branch information
Sonicadvance1 authored Jul 3, 2024
2 parents 02a218c + ad52514 commit f453e15
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 61 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
5 changes: 1 addition & 4 deletions FEXCore/unittests/APITests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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$$")

5 changes: 1 addition & 4 deletions FEXCore/unittests/Emitter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
5 changes: 1 addition & 4 deletions Source/Tools/LinuxEmulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*")
5 changes: 1 addition & 4 deletions unittests/32Bit_ASM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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$$")
5 changes: 1 addition & 4 deletions unittests/APITests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
7 changes: 2 additions & 5 deletions unittests/ASM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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$$")
9 changes: 3 additions & 6 deletions unittests/FEXLinuxTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
)

Expand All @@ -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
)
7 changes: 2 additions & 5 deletions unittests/InstructionCountCI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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$$")
5 changes: 1 addition & 4 deletions unittests/POSIX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
9 changes: 3 additions & 6 deletions unittests/ThunkFunctionalTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
5 changes: 1 addition & 4 deletions unittests/ThunkLibs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 1 addition & 4 deletions unittests/gcc-target-tests-32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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$$")
5 changes: 1 addition & 4 deletions unittests/gcc-target-tests-64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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$$")
4 changes: 1 addition & 3 deletions unittests/gvisor-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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$$")

0 comments on commit f453e15

Please sign in to comment.