From 84bb62f39710afc9a6901835306f8a18f70d9d1a Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 13:17:24 +0200 Subject: [PATCH] Switched back to a single executable for test Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 8 ++--- Makefile | 22 ++++--------- test/CMakeLists.txt | 57 +++++++++++++++------------------ 3 files changed, 37 insertions(+), 50 deletions(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index 4a7dcbad2..8f7ea42d3 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -27,7 +27,7 @@ jobs: cc: gcc cxx: g++ build-type: Debug - run-test: true + run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON @@ -51,7 +51,7 @@ jobs: cc: gcc cxx: g++ build-type: Release - run-test: true + run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON @@ -75,7 +75,7 @@ jobs: cc: gcc cxx: g++ build-type: Debug - run-test: true + run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON @@ -99,6 +99,6 @@ jobs: cc: gcc cxx: g++ build-type: Release - run-test: true + run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON diff --git a/Makefile b/Makefile index 7a9065c9e..945bbfcea 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ VCPKG_WIN_PATH ?= "C:\\Users\\axsau\\Programming\\lib\\vcpkg\\scripts\\buildsyst VCPKG_UNIX_PATH ?= "/c/Users/axsau/Programming/lib/vcpkg/scripts/buildsystems/vcpkg.cmake" # These are the tests that don't work with swiftshader but can be run directly with vulkan -FILTER_TESTS_REGEX ?= "(kompute_AsyncOperations_tests)|(kompute_PushConstant_tests)" +FILTER_TESTS ?= "-TestAsyncOperations.TestManagerParallelExecution:TestSequence.SequenceTimestamps:TestPushConstants.TestConstantsDouble" ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... CMAKE_BIN ?= "C:\Program Files\CMake\bin\cmake.exe" @@ -78,25 +78,17 @@ mk_build_kompute: cmake --build build/. --target kompute --parallel mk_build_tests: - cmake --build build/. --target AsyncOperations_tests \ - Destroy_tests \ - LogisticRegression_tests \ - Manager_tests \ - MultipleAlgoExecutions_tests \ - OpShadersFromStringAndFile_tests \ - OpTensorCopy_tests \ - OpTensorCreate_tests \ - PushConstant_tests \ - Sequence_tests \ - SpecializationConstant_tests \ - Workgroup_tests \ + cmake --build build/. --target kompute_tests \ --parallel mk_run_docs: mk_build_docs (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) +# An alternative would be: ctest -vv --test-dir build/. +# But this is not possible since we need to filter specific tests, not complete executables, which is not possible with ctest. +# https://gitlab.kitware.com/cmake/cmake/-/issues/13168 mk_run_tests: mk_build_tests - ctest -vv --exclude-regex $(FILTER_TESTS_REGEX) --test-dir build/. + ./build/bin/kompute_tests --gtest_filter=$(FILTER_TESTS) mk_build_swiftshader_library: git clone https://github.com/google/swiftshader || echo "Assuming already cloned" @@ -149,7 +141,7 @@ vs_run_docs: vs_build_docs (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) vs_run_tests: vs_build_tests - ctest -vv --exclude-regex $(FILTER_TESTS_REGEX) --test-dir build/. + ./build/test/$(VS_BUILD_TYPE)/bin/kompute_tests.exe --gtest_filter=$(FILTER_TESTS) #### PYTHONG #### diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6f1ad80c6..0342a2822 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,37 +10,32 @@ add_subdirectory(shaders) # #################################################### # Tests # #################################################### -macro(add_kompute_test _TEST_NAME) - add_executable("${_TEST_NAME}_tests" "Test${_TEST_NAME}.cpp" - ${ARGN}) - target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::gtest_main - kompute::kompute - kp_logger - test_shaders - test_shaders_glsl) - add_test(NAME "kompute_${_TEST_NAME}_tests" COMMAND "${_TEST_NAME}_tests") +add_executable(kompute_tests TestAsyncOperations.cpp + TestDestroy.cpp + TestLogisticRegression.cpp + TestManager.cpp + TestMultipleAlgoExecutions.cpp + TestOpShadersFromStringAndFile.cpp + TestOpTensorCopy.cpp + TestOpTensorCreate.cpp + TestPushConstant.cpp + TestSequence.cpp + TestSpecializationConstant.cpp + TestWorkgroup.cpp) - # Group under the "tests" project folder in IDEs such as Visual Studio. - set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") +target_link_libraries(kompute_tests PRIVATE GTest::gtest_main + kompute::kompute + kp_logger + test_shaders + test_shaders_glsl) +add_test(NAME kompute_tests COMMAND kompute_tests) - if(WIN32 AND BUILD_SHARED_LIBS AND NOT FILES_COPYED) # Install dlls in the same directory as the executable on Windows so one can simply double click them - set(FILES_COPYED "DONE") - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - endif() -endmacro() +# Group under the "tests" project folder in IDEs such as Visual Studio. +set_property(TARGET kompute_tests PROPERTY FOLDER "tests") -add_kompute_test(AsyncOperations) -add_kompute_test(Destroy) -add_kompute_test(LogisticRegression) -add_kompute_test(Manager) -add_kompute_test(MultipleAlgoExecutions) -add_kompute_test(OpShadersFromStringAndFile) -add_kompute_test(OpTensorCopy) -add_kompute_test(OpTensorCreate) -add_kompute_test(PushConstant) -add_kompute_test(Sequence) -add_kompute_test(SpecializationConstant) -add_kompute_test(Workgroup) +if(WIN32 AND BUILD_SHARED_LIBS) # Install dlls in the same directory as the executable on Windows so one can simply double click them + add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) +endif()