Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] Simplify creation of tests #114

Merged
merged 7 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,9 @@ are described below.
To install the library, type:
make install

To run the installation test, type:
To run the regression tests, type:
make test (or: ctest)

The test results are in the files below:
build/TESTING/s_test.out # single precision, real
build/TESTING/d_test.out # double precision, real
build/TESTING/c_test.out # single precision, complex
build/TESTING/z_test.out # double precision, complex


2. Manual installation with makefile.
Before installing the package, please examine the three things dependent
Expand Down
117 changes: 35 additions & 82 deletions TESTING/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,117 +5,70 @@ set(test_link_libs matgen)

add_subdirectory(MATGEN)

set(ALINTST sp_ienv.c)
set(NVAL 9 19)
set(NRHS 2)
set(LWORK 0 10000000)

function(cat IN_FILE OUT_FILE)
file(READ ${IN_FILE} CONTENTS)
file(APPEND ${OUT_FILE} "${CONTENTS}")
endfunction()


function(add_superlu_test output input target)
set(TEST_INPUT "${SuperLU_SOURCE_DIR}/EXAMPLE/${input}")
set(TEST_OUTPUT "${SuperLU_BINARY_DIR}/TESTING/${output}")

# Prepare a temporary file to "cat" to:
# "== LAPACK test matrices"
file(WRITE ${TEST_OUTPUT} "")

## get_target_property(TEST_LOC ${target} LOCATION)
set(TEST_LOC ${CMAKE_CURRENT_BINARY_DIR})

foreach (n ${NVAL})
foreach (s ${NRHS})
foreach(l ${LWORK})
set(testName "${target}_${n}_${s}_${l}")
set(SINGLE_OUTPUT ${SuperLU_BINARY_DIR}/TESTING/${testName}.out)
add_test( ${testName}_LA "${CMAKE_COMMAND}"
-DTEST=${TEST_LOC} -t "LA" -n ${n} -s ${s} -l ${l}
-DOUTPUT=${SINGLE_OUTPUT}
-DALL_OUTPUT=${TEST_OUTPUT}
-DHEADING=Dense\ matrix\ --\ n=${n},\ s=${s},\ lwork=${l}
-P "${SuperLU_SOURCE_DIR}/TESTING/runtest.cmake"
)
foreach (s ${NRHS})
foreach(l ${LWORK})
# LA tests
foreach (n ${NVAL})
set(testName "${target}_${n}_${s}_${l}")
add_test(
NAME ${testName}_LA
COMMAND ${target} -t "LA" -n ${n} -s ${s} -l ${l})
endforeach()

# SP tests
set(testName "${target}_${s}_${l}")
add_test(
NAME ${testName}_SP
COMMAND ${target} -t "SP" -s ${s} -l ${l} -f "${TEST_INPUT}")
endforeach()
endforeach()

# file(APPEND ${TEST_OUTPUT} "== sparse matrix\n")

foreach (s ${NRHS})
foreach(l ${LWORK})
set(testName "${target}_${s}_${l}")
set(SINGLE_OUTPUT ${SuperLU_BINARY_DIR}/TESTING/${testName}.out)
add_test( ${testName}_SP "${CMAKE_COMMAND}"
-DTEST=${TEST_LOC} -t "SP" -s ${s} -l ${l} -f ${TEST_INPUT}
-DOUTPUT=${SINGLE_OUTPUT}
-DALL_OUTPUT=${TEST_OUTPUT}
-DHEADING=Sparse\ matrix\ ${TEST_INPUT}\ --\ s=${s},\ lwork=${l}
-P "${SuperLU_SOURCE_DIR}/TESTING/runtest.cmake")
endforeach()
endforeach()
# Add getopt dependency to target in case of MSVC
if(MSVC)
target_include_directories(${target} PRIVATE ${WinGetOpt_INCLUDE_DIR})
target_link_libraries(${target} ${WinGetOpt_LIBRARY})
endif()

endfunction(add_superlu_test)


if(enable_single)
set(SLINTST sdrive.c sp_sconvert.c sgst01.c sgst02.c sgst04.c sgst07.c)

add_executable(s_test ${ALINTST} ${SLINTST})
add_executable(s_test
sdrive.c sgst01.c sgst02.c sgst04.c sgst07.c
sp_ienv.c sp_sconvert.c)
target_link_libraries(s_test ${test_link_libs})

if(MSVC)
target_include_directories(s_test PRIVATE ${WinGetOpt_INCLUDE_DIR})
target_link_libraries(s_test ${WinGetOpt_LIBRARY})
endif()

add_superlu_test(s_test.out g20.rua s_test)

add_superlu_test(s_test g20.rua)
endif()


if(enable_double)
set(DLINTST ddrive.c sp_dconvert.c dgst01.c dgst02.c dgst04.c dgst07.c)

add_executable(d_test ${ALINTST} ${DLINTST})
add_executable(d_test
ddrive.c dgst01.c dgst02.c dgst04.c dgst07.c
sp_ienv.c sp_dconvert.c)
target_link_libraries(d_test ${test_link_libs})

if(MSVC)
target_include_directories(d_test PRIVATE ${WinGetOpt_INCLUDE_DIR})
target_link_libraries(d_test ${WinGetOpt_LIBRARY})
endif()

add_superlu_test(d_test.out g20.rua d_test)
add_superlu_test(d_test g20.rua)
endif()

if(enable_complex)
set(CLINTST cdrive.c sp_cconvert.c cgst01.c cgst02.c cgst04.c cgst07.c)

add_executable(c_test ${ALINTST} ${CLINTST})
add_executable(c_test
cdrive.c cgst01.c cgst02.c cgst04.c cgst07.c
sp_ienv.c sp_cconvert.c)
target_link_libraries(c_test ${test_link_libs})

if(MSVC)
target_include_directories(c_test PRIVATE ${WinGetOpt_INCLUDE_DIR})
target_link_libraries(c_test ${WinGetOpt_LIBRARY})
endif()

add_superlu_test(c_test.out cg20.cua c_test)
add_superlu_test(c_test cg20.cua)
endif()


if(enable_complex16)
set(ZLINTST zdrive.c sp_zconvert.c zgst01.c zgst02.c zgst04.c zgst07.c)

add_executable(z_test ${ALINTST} ${ZLINTST})
add_executable(z_test
zdrive.c zgst01.c zgst02.c zgst04.c zgst07.c
sp_ienv.c sp_zconvert.c)
target_link_libraries(z_test ${test_link_libs})

if(MSVC)
target_include_directories(z_test PRIVATE ${WinGetOpt_INCLUDE_DIR})
target_link_libraries(z_test ${WinGetOpt_LIBRARY})
endif()

add_superlu_test(z_test.out cg20.cua z_test)
add_superlu_test(z_test cg20.cua)
endif()
9 changes: 0 additions & 9 deletions TESTING/runtest.cmake

This file was deleted.

Loading