From 7c5eb4cb32d59eff55e8476feef13b86c7e53790 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Mon, 16 Sep 2024 21:39:45 +0200 Subject: [PATCH] ci --- ci/run_ctests.sh | 14 ++++++++++++-- cpp/examples/CMakeLists.txt | 30 ++++++++++++++++++------------ cpp/tests/CMakeLists.txt | 2 ++ cpp/tests/utils.hpp | 13 ++++++++----- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/ci/run_ctests.sh b/ci/run_ctests.sh index 069490facf..11c6353314 100755 --- a/ci/run_ctests.sh +++ b/ci/run_ctests.sh @@ -6,5 +6,15 @@ set -euo pipefail # Support customizing the ctests' install location cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/tests/libkvikio/" -# Run BASIC_IO_TEST -./BASIC_IO_TEST +pwd +ls -la +which ctest + + +# Run basic tests +./BASIC_IO_EXAMPLE +./BASIC_NO_CUDA_EXAMPLE + +# Run gtests +./cpp_tests +ctest --no-tests=error --output-on-failure "$@" diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt index c12ddb2e52..5124c9ef71 100644 --- a/cpp/examples/CMakeLists.txt +++ b/cpp/examples/CMakeLists.txt @@ -14,19 +14,23 @@ set(TEST_INSTALL_PATH bin/tests/libkvikio) +# Example: basic_io + if(CUDAToolkit_FOUND) - add_executable(BASIC_IO_TEST basic_io.cpp) - set_target_properties(BASIC_IO_TEST PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") - target_include_directories(BASIC_IO_TEST PRIVATE ../include ${cuFile_INCLUDE_DIRS}) - target_link_libraries(BASIC_IO_TEST PRIVATE kvikio CUDA::cudart) + add_executable(BASIC_IO_EXAMPLE basic_io.cpp) + set_target_properties(BASIC_IO_EXAMPLE PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") + target_include_directories(BASIC_IO_EXAMPLE PRIVATE ../include ${cuFile_INCLUDE_DIRS}) + target_link_libraries(BASIC_IO_EXAMPLE PRIVATE kvikio CUDA::cudart) if(CMAKE_COMPILER_IS_GNUCXX) set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") - target_compile_options(BASIC_IO_TEST PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>") + target_compile_options( + BASIC_IO_EXAMPLE PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>" + ) endif() install( - TARGETS BASIC_IO_TEST + TARGETS BASIC_IO_EXAMPLE COMPONENT testing DESTINATION ${TEST_INSTALL_PATH} EXCLUDE_FROM_ALL @@ -35,20 +39,22 @@ else() message(STATUS "Cannot build the basic_io example when CUDA is not found") endif() -add_executable(BASIC_NO_CUDA_TEST basic_no_cuda.cpp) -set_target_properties(BASIC_NO_CUDA_TEST PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") -target_include_directories(BASIC_NO_CUDA_TEST PRIVATE ../include) -target_link_libraries(BASIC_NO_CUDA_TEST PRIVATE kvikio) +# Example: basic_no_cuda + +add_executable(BASIC_NO_CUDA_EXAMPLE basic_no_cuda.cpp) +set_target_properties(BASIC_NO_CUDA_EXAMPLE PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") +target_include_directories(BASIC_NO_CUDA_EXAMPLE PRIVATE ../include) +target_link_libraries(BASIC_NO_CUDA_EXAMPLE PRIVATE kvikio) if(CMAKE_COMPILER_IS_GNUCXX) set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") target_compile_options( - BASIC_NO_CUDA_TEST PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>" + BASIC_NO_CUDA_EXAMPLE PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>" ) endif() install( - TARGETS BASIC_NO_CUDA_TEST + TARGETS BASIC_NO_CUDA_EXAMPLE COMPONENT testing DESTINATION ${TEST_INSTALL_PATH} EXCLUDE_FROM_ALL diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 1b625e7f52..987029d76d 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -38,3 +38,5 @@ rapids_test_add( COMMAND cpp_tests INSTALL_COMPONENT_SET testing ) + +rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/tests/libkvikio) diff --git a/cpp/tests/utils.hpp b/cpp/tests/utils.hpp index 7132ec72ef..991b2b773b 100644 --- a/cpp/tests/utils.hpp +++ b/cpp/tests/utils.hpp @@ -102,8 +102,15 @@ class TempDir { std::filesystem::path _dir_path{}; }; +/** + * @brief Help class for creating and comparing buffers. + */ class DevBuffer { public: + const std::size_t nelem; + const std::size_t nbytes; + void* ptr{nullptr}; + DevBuffer(std::size_t nelem) : nelem{nelem}, nbytes{nelem * sizeof(std::int64_t)} { KVIKIO_CHECK_CUDA(cudaMalloc(&ptr, nbytes)); @@ -144,13 +151,9 @@ class DevBuffer { } std::cout << ")" << std::endl; } - - const std::size_t nelem; - const std::size_t nbytes; - void* ptr{nullptr}; }; -void expect_equal(const DevBuffer& a, const DevBuffer& b) +inline void expect_equal(const DevBuffer& a, const DevBuffer& b) { EXPECT_EQ(a.nbytes, b.nbytes); auto a_vec = a.to_vector();