From c8728aa871c6ae2ed6a4d9e3007ef30d417c4b54 Mon Sep 17 00:00:00 2001 From: wo80 Date: Tue, 8 Aug 2023 12:18:12 +0200 Subject: [PATCH 1/5] [cmake] Fix and simplify test setup --- TESTING/CMakeLists.txt | 89 +++++++++++++----------------------------- 1 file changed, 27 insertions(+), 62 deletions(-) diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index 82c8e46c..55146b25 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -5,82 +5,47 @@ 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) +function(add_superlu_test target input) 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" - ) - endforeach() - 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") + 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() endfunction(add_superlu_test) if(enable_single) - set(SLINTST sdrive.c sp_sconvert.c sgst01.c sgst02.c sgst04.c sgst07.c) + set(SLINTST sdrive.c sp_ienv.c sp_sconvert.c sgst01.c sgst02.c sgst04.c sgst07.c) - add_executable(s_test ${ALINTST} ${SLINTST}) + add_executable(s_test ${SLINTST}) 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) + set(DLINTST ddrive.c sp_ienv.c sp_dconvert.c dgst01.c dgst02.c dgst04.c dgst07.c) - add_executable(d_test ${ALINTST} ${DLINTST}) + add_executable(d_test ${DLINTST}) target_link_libraries(d_test ${test_link_libs}) if(MSVC) @@ -88,13 +53,13 @@ if(enable_double) 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) + set(CLINTST cdrive.c sp_ienv.c sp_cconvert.c cgst01.c cgst02.c cgst04.c cgst07.c) - add_executable(c_test ${ALINTST} ${CLINTST}) + add_executable(c_test ${CLINTST}) target_link_libraries(c_test ${test_link_libs}) if(MSVC) @@ -102,14 +67,14 @@ if(enable_complex) 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) + set(ZLINTST zdrive.c sp_ienv.c sp_zconvert.c zgst01.c zgst02.c zgst04.c zgst07.c) - add_executable(z_test ${ALINTST} ${ZLINTST}) + add_executable(z_test ${ZLINTST}) target_link_libraries(z_test ${test_link_libs}) if(MSVC) @@ -117,5 +82,5 @@ if(enable_complex16) 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() From ddec0c9e6be67e31a9d392d24d1c1918aafd9499 Mon Sep 17 00:00:00 2001 From: wo80 Date: Tue, 8 Aug 2023 12:22:20 +0200 Subject: [PATCH 2/5] [cmake] Delete unused runtest.cmake --- TESTING/runtest.cmake | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 TESTING/runtest.cmake diff --git a/TESTING/runtest.cmake b/TESTING/runtest.cmake deleted file mode 100644 index 1ab16a2f..00000000 --- a/TESTING/runtest.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# execute the test command that was added earlier. -execute_process( COMMAND "${TEST}" - OUTPUT_FILE "${OUTPUT}" - RESULT_VARIABLE RET ) -file(APPEND ${ALL_OUTPUT} ${HEADING}) -file(APPEND ${ALL_OUTPUT} "\n") -file(READ "${OUTPUT}" SINGLE_OUTPUT) -file(APPEND ${ALL_OUTPUT} "${SINGLE_OUTPUT}\n") -file(REMOVE ${OUTPUT}) # remove the individual output file. From 9c95a8e607fa5d7e4d2884c5f4bcb32b3c50c8be Mon Sep 17 00:00:00 2001 From: wo80 Date: Sat, 12 Aug 2023 22:41:42 +0200 Subject: [PATCH 3/5] [cmake] Fix getopt dependency for MSVC compiler in test setup --- TESTING/CMakeLists.txt | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index 55146b25..0ab5800d 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -30,6 +30,12 @@ function(add_superlu_test target input) 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) @@ -47,11 +53,6 @@ if(enable_double) add_executable(d_test ${DLINTST}) 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 g20.rua) endif() @@ -61,11 +62,6 @@ if(enable_complex) add_executable(c_test ${CLINTST}) 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 cg20.cua) endif() @@ -76,11 +72,6 @@ if(enable_complex16) add_executable(z_test ${ZLINTST}) 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 cg20.cua) endif() From 992141436fca829a984efb6efe7a0d054eaed74c Mon Sep 17 00:00:00 2001 From: wo80 Date: Mon, 11 Sep 2023 19:08:18 +0200 Subject: [PATCH 4/5] Change Github workflow to use cmake. --- .github/workflows/test.yml | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f9e9cd12..c3bfcb1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: test: name: Build and test - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: matrix: @@ -14,23 +14,16 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install dependencies - run: sudo apt-get install csh clang + run: sudo apt-get install cmake + + - name: Configure + run: cmake -B build - name: Build - run: | - cp MAKE_INC/make.linux make.inc - # We use ~ instead of / as a separator in sed, since $(pwd) - # also includes / - sed -i "s~^SuperLUroot\s*=.*~SuperLUroot = $(pwd)~g" make.inc - sed -i "s/^CC\s*=.*/CC = ${CC_CI}/g" make.inc - mkdir lib - make install lib - env: - CC_CI: ${{ matrix.compiler }} - + run: cmake --build build --parallel + - name: Test - run: | - make testing + run: ctest --test-dir build --output-on-failure From 697e256c9ebe14b61f55d6b0ecd15c0d344089eb Mon Sep 17 00:00:00 2001 From: wo80 Date: Mon, 11 Sep 2023 19:09:43 +0200 Subject: [PATCH 5/5] Make test drivers return code reflect failure status. --- TESTING/cdrive.c | 2 +- TESTING/ddrive.c | 2 +- TESTING/sdrive.c | 2 +- TESTING/zdrive.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TESTING/cdrive.c b/TESTING/cdrive.c index 7aab33e6..6df0634c 100644 --- a/TESTING/cdrive.c +++ b/TESTING/cdrive.c @@ -513,7 +513,7 @@ int main(int argc, char *argv[]) Destroy_SuperMatrix_Store(&U); } - return 0; + return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } /*! diff --git a/TESTING/ddrive.c b/TESTING/ddrive.c index ddce4752..116d2310 100644 --- a/TESTING/ddrive.c +++ b/TESTING/ddrive.c @@ -512,7 +512,7 @@ int main(int argc, char *argv[]) Destroy_SuperMatrix_Store(&U); } - return 0; + return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } /*! diff --git a/TESTING/sdrive.c b/TESTING/sdrive.c index 9dc24ffc..c267a528 100644 --- a/TESTING/sdrive.c +++ b/TESTING/sdrive.c @@ -513,7 +513,7 @@ int main(int argc, char *argv[]) Destroy_SuperMatrix_Store(&U); } - return 0; + return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } /*! diff --git a/TESTING/zdrive.c b/TESTING/zdrive.c index 7f091a5a..c361004e 100644 --- a/TESTING/zdrive.c +++ b/TESTING/zdrive.c @@ -512,7 +512,7 @@ int main(int argc, char *argv[]) Destroy_SuperMatrix_Store(&U); } - return 0; + return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } /*!