Skip to content

Commit

Permalink
Refactor test-suite
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Oct 27, 2023
1 parent cfa4e33 commit e3b23da
Show file tree
Hide file tree
Showing 23 changed files with 284 additions and 19 deletions.
94 changes: 75 additions & 19 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,75 @@
# Build program.
add_executable(strings strings.c)
add_executable(gksort gksort.c)
add_executable(fis fis.c)
add_executable(gkrw rw.c)
add_executable(gkgraph gkgraph.c)
add_executable(csrcnv csrcnv.c)
add_executable(grKx grKx.c)
add_executable(m2mnbrs m2mnbrs.c)
add_executable(cmpnbrs cmpnbrs.c)
add_executable(splatt2svd splatt2svd.c)
add_executable(gkuniq gkuniq.c)

foreach(prog strings gksort fis gkrw gkgraph csrcnv grKx m2mnbrs cmpnbrs splatt2svd gkuniq)
target_link_libraries(${prog} GKlib)
endforeach(prog)

# Install a subset of them
install(TARGETS csrcnv RUNTIME DESTINATION bin)
function(GKlib_add_test test)
#[===[.md
# GKlib_add_test

Internal helper for adding GKlib tests

## Synopsis
```cmake
GKlib_add_test(<name>
[TEST_NAME <test_name>]
[TARGET <target>]
[LABELS <label1> <label2>])
```

## Options

`<name>`
Path to the CMake project to be executed relative to `${CMAKE_CURRENT_SOURCE_DIR}`

`TEST_NAME` [Default: `<name>`]
Name for the test to be used as the ctest name

`LABELS`
Additional labels to be added

]===]

set(ARGS_Options)
set(ARGS_OneValue
TEST_NAME
)
set(ARGS_MultiValue
LABELS
)
cmake_parse_arguments(PARSE_ARGV 1 ARGS "${ARGS_Options}" "${ARGS_OneValue}" "${ARGS_MultiValue}")
# Check required/optional arguments
if (ARGC LESS 1)
message(FATAL_ERROR
"Fortuno: Missing test name in Octopus_add_test call")
endif ()
if (NOT DEFINED ARGS_TEST_NAME)
set(ARGS_TEST_NAME ${test})
endif ()

add_test(NAME ${ARGS_TEST_NAME}
COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/${test}
${CMAKE_CURRENT_BINARY_DIR}/${test}
--build-generator "${CMAKE_GENERATOR}"
--build-options -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
# Generated Config file point to binary targets until it is installed
-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS
-DGKlib_ROOT=${PROJECT_BINARY_DIR}
# TODO: Implement recursive ctest and remove --notests flag
--test-command ${CMAKE_CTEST_COMMAND} --test-dir ${CMAKE_CURRENT_BINARY_DIR}/${test} --no-tests=ignore
)
set_tests_properties(${ARGS_TEST_NAME} PROPERTIES
LABELS "${ARGS_LABELS}"
)
endfunction()

foreach (test IN ITEMS
cmpnbrs
csrcnv
fis
gkgraph
gksort
gkuniq
grKx
m2mnbrs
rw
splatt2svd
strings
)
GKlib_add_test(${test})
endforeach ()
19 changes: 19 additions & 0 deletions test/cmpnbrs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(cmpnbrs
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(cmpnbrs cmpnbrs.c)
target_link_libraries(cmpnbrs PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/csrcnv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(csrcnv
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(csrcnv csrcnv.c)
target_link_libraries(csrcnv PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/fis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(fis
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(fis fis.c)
target_link_libraries(fis PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/gkgraph/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(gkgraph
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(gkgraph gkgraph.c)
target_link_libraries(gkgraph.c PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/gksort/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(gksort
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(gksort gksort.c)
target_link_libraries(gksort PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/gkuniq/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(gkuniq
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(gkuniq gkuniq.c)
target_link_libraries(gkuniq PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/grKx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(grKx
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(grKx grKx.c)
target_link_libraries(grKx PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/m2mnbrs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(m2mnbrs
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(m2mnbrs m2mnbrs.c)
target_link_libraries(m2mnbrs PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/rw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(rw
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(rw rw.c)
target_link_libraries(rw PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/splatt2svd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(splatt2svd
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(splatt2svd splatt2svd.c)
target_link_libraries(splatt2svd PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.
19 changes: 19 additions & 0 deletions test/strings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)

project(strings
LANGUAGES C
)

include(FetchContent)
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
GIT_TAG master
FIND_PACKAGE_ARGS CONFIG
)
FetchContent_MakeAvailable(GKlib)

add_executable(strings strings.c)
target_link_libraries(strings PRIVATE GKlib::GKlib)

# TODO: Add ctest calling for each internal project
enable_testing()
File renamed without changes.

0 comments on commit e3b23da

Please sign in to comment.