Skip to content

Commit 0a6de8c

Browse files
committed
Refactor test-suite
Signed-off-by: Cristian Le <[email protected]>
1 parent 43900ef commit 0a6de8c

File tree

23 files changed

+284
-19
lines changed

23 files changed

+284
-19
lines changed

test/CMakeLists.txt

Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,75 @@
1-
# Build program.
2-
add_executable(strings strings.c)
3-
add_executable(gksort gksort.c)
4-
add_executable(fis fis.c)
5-
add_executable(gkrw rw.c)
6-
add_executable(gkgraph gkgraph.c)
7-
add_executable(csrcnv csrcnv.c)
8-
add_executable(grKx grKx.c)
9-
add_executable(m2mnbrs m2mnbrs.c)
10-
add_executable(cmpnbrs cmpnbrs.c)
11-
add_executable(splatt2svd splatt2svd.c)
12-
add_executable(gkuniq gkuniq.c)
13-
14-
foreach(prog strings gksort fis gkrw gkgraph csrcnv grKx m2mnbrs cmpnbrs splatt2svd gkuniq)
15-
target_link_libraries(${prog} GKlib)
16-
endforeach(prog)
17-
18-
# Install a subset of them
19-
install(TARGETS csrcnv RUNTIME DESTINATION bin)
1+
function(GKlib_add_test test)
2+
#[===[.md
3+
# GKlib_add_test
4+
5+
Internal helper for adding GKlib tests
6+
7+
## Synopsis
8+
```cmake
9+
GKlib_add_test(<name>
10+
[TEST_NAME <test_name>]
11+
[TARGET <target>]
12+
[LABELS <label1> <label2>])
13+
```
14+
15+
## Options
16+
17+
`<name>`
18+
Path to the CMake project to be executed relative to `${CMAKE_CURRENT_SOURCE_DIR}`
19+
20+
`TEST_NAME` [Default: `<name>`]
21+
Name for the test to be used as the ctest name
22+
23+
`LABELS`
24+
Additional labels to be added
25+
26+
]===]
27+
28+
set(ARGS_Options)
29+
set(ARGS_OneValue
30+
TEST_NAME
31+
)
32+
set(ARGS_MultiValue
33+
LABELS
34+
)
35+
cmake_parse_arguments(PARSE_ARGV 1 ARGS "${ARGS_Options}" "${ARGS_OneValue}" "${ARGS_MultiValue}")
36+
# Check required/optional arguments
37+
if (ARGC LESS 1)
38+
message(FATAL_ERROR
39+
"Fortuno: Missing test name in Octopus_add_test call")
40+
endif ()
41+
if (NOT DEFINED ARGS_TEST_NAME)
42+
set(ARGS_TEST_NAME ${test})
43+
endif ()
44+
45+
add_test(NAME ${ARGS_TEST_NAME}
46+
COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/${test}
47+
${CMAKE_CURRENT_BINARY_DIR}/${test}
48+
--build-generator "${CMAKE_GENERATOR}"
49+
--build-options -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
50+
# Generated Config file point to binary targets until it is installed
51+
-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS
52+
-DGKlib_ROOT=${PROJECT_BINARY_DIR}
53+
# TODO: Implement recursive ctest and remove --notests flag
54+
--test-command ${CMAKE_CTEST_COMMAND} --test-dir ${CMAKE_CURRENT_BINARY_DIR}/${test} --no-tests=ignore
55+
)
56+
set_tests_properties(${ARGS_TEST_NAME} PROPERTIES
57+
LABELS "${ARGS_LABELS}"
58+
)
59+
endfunction()
60+
61+
foreach (test IN ITEMS
62+
cmpnbrs
63+
csrcnv
64+
fis
65+
gkgraph
66+
gksort
67+
gkuniq
68+
grKx
69+
m2mnbrs
70+
rw
71+
splatt2svd
72+
strings
73+
)
74+
GKlib_add_test(${test})
75+
endforeach ()

test/cmpnbrs/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(cmpnbrs
4+
LANGUAGES C
5+
)
6+
7+
include(FetchContent)
8+
FetchContent_Declare(GKlib
9+
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
10+
GIT_TAG master
11+
FIND_PACKAGE_ARGS CONFIG
12+
)
13+
FetchContent_MakeAvailable(GKlib)
14+
15+
add_executable(cmpnbrs cmpnbrs.c)
16+
target_link_libraries(cmpnbrs PRIVATE GKlib::GKlib)
17+
18+
# TODO: Add ctest calling for each internal project
19+
enable_testing()
File renamed without changes.

test/csrcnv/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(csrcnv
4+
LANGUAGES C
5+
)
6+
7+
include(FetchContent)
8+
FetchContent_Declare(GKlib
9+
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
10+
GIT_TAG master
11+
FIND_PACKAGE_ARGS CONFIG
12+
)
13+
FetchContent_MakeAvailable(GKlib)
14+
15+
add_executable(csrcnv csrcnv.c)
16+
target_link_libraries(csrcnv PRIVATE GKlib::GKlib)
17+
18+
# TODO: Add ctest calling for each internal project
19+
enable_testing()
File renamed without changes.

test/fis/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(fis
4+
LANGUAGES C
5+
)
6+
7+
include(FetchContent)
8+
FetchContent_Declare(GKlib
9+
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
10+
GIT_TAG master
11+
FIND_PACKAGE_ARGS CONFIG
12+
)
13+
FetchContent_MakeAvailable(GKlib)
14+
15+
add_executable(fis fis.c)
16+
target_link_libraries(fis PRIVATE GKlib::GKlib)
17+
18+
# TODO: Add ctest calling for each internal project
19+
enable_testing()
File renamed without changes.

test/gkgraph/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(gkgraph
4+
LANGUAGES C
5+
)
6+
7+
include(FetchContent)
8+
FetchContent_Declare(GKlib
9+
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
10+
GIT_TAG master
11+
FIND_PACKAGE_ARGS CONFIG
12+
)
13+
FetchContent_MakeAvailable(GKlib)
14+
15+
add_executable(gkgraph gkgraph.c)
16+
target_link_libraries(gkgraph.c PRIVATE GKlib::GKlib)
17+
18+
# TODO: Add ctest calling for each internal project
19+
enable_testing()
File renamed without changes.

test/gksort/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(gksort
4+
LANGUAGES C
5+
)
6+
7+
include(FetchContent)
8+
FetchContent_Declare(GKlib
9+
GIT_REPOSITORY https://github.com/KarypisLab/GKlib
10+
GIT_TAG master
11+
FIND_PACKAGE_ARGS CONFIG
12+
)
13+
FetchContent_MakeAvailable(GKlib)
14+
15+
add_executable(gksort gksort.c)
16+
target_link_libraries(gksort PRIVATE GKlib::GKlib)
17+
18+
# TODO: Add ctest calling for each internal project
19+
enable_testing()

0 commit comments

Comments
 (0)