diff --git a/.github/workflows/cmake-single-platform.yml b/.github/workflows/cmake-single-platform.yml index 0ac33d9..c68a3ad 100644 --- a/.github/workflows/cmake-single-platform.yml +++ b/.github/workflows/cmake-single-platform.yml @@ -32,7 +32,7 @@ jobs: run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - name: Test - working-directory: ${{github.workspace}}/build + working-directory: ${{github.workspace}}/build/test # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail run: ctest -C ${{env.BUILD_TYPE}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 9efd9db..eea4062 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,58 +7,11 @@ add_library(cmatrix STATIC src/sparse.c src/dense.c include/sparse.h include/dense.h - test/dense_mread/test_mread.c ) target_include_directories(cmatrix PUBLIC include) -# Enable testing -enable_testing() +add_subdirectory(test) -# Test executable for mread -add_executable(test_sparse_mread test/sparse_mread/test_mread.c) -target_link_libraries(test_sparse_mread PRIVATE cmatrix) -target_include_directories(test_sparse_mread PRIVATE include) -configure_file( - ${CMAKE_SOURCE_DIR}/test/sparse_mread/mread_input_0.txt - ${CMAKE_BINARY_DIR}/sparse_mread_input_0.txt - COPYONLY -) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/sparse_mread/mread_input_1.txt - ${CMAKE_BINARY_DIR}/sparse_mread_input_1.txt - COPYONLY -) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/sparse_mread/mread_input_2.txt - ${CMAKE_BINARY_DIR}/sparse_mread_input_2.txt - COPYONLY -) - -add_test(NAME test_sparse_mread COMMAND test_sparse_mread) -add_executable(test_dense_mread test/dense_mread/test_mread.c) -target_link_libraries(test_dense_mread PRIVATE cmatrix) -target_include_directories(test_dense_mread PRIVATE include) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/dense_mread/mread_input_0.txt; - ${CMAKE_BINARY_DIR}/dense_mread_input_0.txt - COPYONLY -) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/dense_mread/mread_input_1.txt; - ${CMAKE_BINARY_DIR}/dense_mread_input_1.txt - COPYONLY -) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/dense_mread/mread_input_2.txt; - ${CMAKE_BINARY_DIR}/dense_mread_input_2.txt - COPYONLY -) -add_test(NAME test_dense_mread COMMAND test_dense_mread) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..d346285 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,5 @@ +enable_testing() + +add_subdirectory(dense_mread) + +add_subdirectory(sparse_mread) \ No newline at end of file diff --git a/test/dense_mread/CMakeLists.txt b/test/dense_mread/CMakeLists.txt new file mode 100644 index 0000000..321f908 --- /dev/null +++ b/test/dense_mread/CMakeLists.txt @@ -0,0 +1,24 @@ +# Test executable for mread +add_executable(test_dense_mread test_mread.c) +target_link_libraries(test_dense_mread PRIVATE cmatrix) +target_include_directories(test_dense_mread PRIVATE ${CMAKE_SOURCE_DIR}/include) + +configure_file( + mread_input_0.txt + dense_mread_input_0.txt + COPYONLY +) + +configure_file( + mread_input_1.txt + dense_mread_input_1.txt + COPYONLY +) + +configure_file( + mread_input_2.txt + dense_mread_input_2.txt + COPYONLY +) + +add_test(NAME test_dense_mread COMMAND test_dense_mread) diff --git a/test/sparse_mread/CMakeLists.txt b/test/sparse_mread/CMakeLists.txt new file mode 100644 index 0000000..3cc23f8 --- /dev/null +++ b/test/sparse_mread/CMakeLists.txt @@ -0,0 +1,24 @@ +# Test executable for mread +add_executable(test_sparse_mread test_mread.c) +target_link_libraries(test_sparse_mread PRIVATE cmatrix) +target_include_directories(test_sparse_mread PRIVATE ${CMAKE_SOURCE_DIR}/include) + +configure_file( + mread_input_0.txt + sparse_mread_input_0.txt + COPYONLY +) + +configure_file( + mread_input_1.txt + sparse_mread_input_1.txt + COPYONLY +) + +configure_file( + mread_input_2.txt + sparse_mread_input_2.txt + COPYONLY +) + +add_test(NAME test_sparse_mread COMMAND test_sparse_mread)