diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04bad35a5e8..d8345485dbd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -149,7 +149,6 @@ jobs: - name: Build run: | cmake --build build -j8 - cmake --install build - name: Report compiler cache if: always() diff --git a/CMakeLists.txt b/CMakeLists.txt index 62843068f6d..5dd6b2752a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,6 @@ option(ENABLE_NATIVE_OPTIMIZATION "Enable compilation optimization for the native machine's CPU type" OFF) option(COMMIT_INFO "Print commit information in log" ON) -option(ENABLE_GOOGLEBENCH "Enable GOOGLE-benchmark usage" OFF) option(ENABLE_JSON "Enable JSON output" OFF) option(ENABLE_CNPY "Enable cnpy usage" OFF) diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index a68871f4b47..cf6985be1fa 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -11,6 +11,24 @@ macro(set_if_higher VARIABLE VALUE) endif() endmacro() +# Prepare runtime inputs in the test working directory without installation. +# configure_file tracks content changes; CONFIGURE_DEPENDS tracks directory entries. +function(abacus_copy_test_files) + foreach(path IN LISTS ARGN) + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${path}") + file(GLOB_RECURSE test_files CONFIGURE_DEPENDS LIST_DIRECTORIES false + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/${path}/*") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${path}") + else() + set(test_files "${path}") + endif() + foreach(test_file IN LISTS test_files) + configure_file("${test_file}" "${test_file}" COPYONLY) + endforeach() + endforeach() +endfunction() + # Add performance test in abacus # Benchmarks are test targets; do not make them implicitly enable the full # unit-test tree for ordinary builds. @@ -66,11 +84,10 @@ endif() target_include_directories(${UT_TARGET} PUBLIC ${CMAKE_BINARY_DIR}/source/source_io) endif() - install(TARGETS ${UT_TARGET} DESTINATION ${CMAKE_BINARY_DIR}/tests) add_test( NAME ${UT_TARGET} COMMAND ${UT_TARGET} - WORKING_DIRECTORY $) + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endfunction(AddTest) if(BUILD_TESTING) diff --git a/source/source_base/module_parallel/test/CMakeLists.txt b/source/source_base/module_parallel/test/CMakeLists.txt index 6f3a2169a7c..8691bf3eab7 100644 --- a/source/source_base/module_parallel/test/CMakeLists.txt +++ b/source/source_base/module_parallel/test/CMakeLists.txt @@ -77,24 +77,25 @@ AddTest( ) target_compile_definitions(MODULE_BASE_para_setup_mpi PRIVATE __MPI) -file(COPY para_world_mpi_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -file(COPY para_collection_mpi_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -file(COPY para_mpi_func_mpi_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -file(COPY para_setup_mpi_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files( + para_world_mpi_test.sh + para_collection_mpi_test.sh + para_mpi_func_mpi_test.sh + para_setup_mpi_test.sh) find_program(BASH bash) add_test(NAME MODULE_BASE_para_world_mpi_test - COMMAND ${BASH} para_world_mpi_test.sh + COMMAND ${BASH} para_world_mpi_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_BASE_para_collection_mpi_test - COMMAND ${BASH} para_collection_mpi_test.sh + COMMAND ${BASH} para_collection_mpi_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_BASE_para_mpi_func_mpi_test - COMMAND ${BASH} para_mpi_func_mpi_test.sh + COMMAND ${BASH} para_mpi_func_mpi_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_BASE_para_setup_mpi_test - COMMAND ${BASH} para_setup_mpi_test.sh + COMMAND ${BASH} para_setup_mpi_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_base/module_parallel/test/para_collection_mpi_test.sh b/source/source_base/module_parallel/test/para_collection_mpi_test.sh index f5baca3b7d0..829e72398e9 100644 --- a/source/source_base/module_parallel/test/para_collection_mpi_test.sh +++ b/source/source_base/module_parallel/test/para_collection_mpi_test.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_para_collection_mpi + mpirun -np $i "${1:-./MODULE_BASE_para_collection_mpi}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_base/module_parallel/test/para_mpi_func_mpi_test.sh b/source/source_base/module_parallel/test/para_mpi_func_mpi_test.sh index afdec3f3ee9..fba021ff4f6 100644 --- a/source/source_base/module_parallel/test/para_mpi_func_mpi_test.sh +++ b/source/source_base/module_parallel/test/para_mpi_func_mpi_test.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_para_mpi_func_mpi + mpirun -np $i "${1:-./MODULE_BASE_para_mpi_func_mpi}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_base/module_parallel/test/para_setup_mpi_test.sh b/source/source_base/module_parallel/test/para_setup_mpi_test.sh index a122b9ed8cb..44407332015 100755 --- a/source/source_base/module_parallel/test/para_setup_mpi_test.sh +++ b/source/source_base/module_parallel/test/para_setup_mpi_test.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_para_setup_mpi + mpirun -np $i "${1:-./MODULE_BASE_para_setup_mpi}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_base/module_parallel/test/para_world_mpi_test.sh b/source/source_base/module_parallel/test/para_world_mpi_test.sh index acfba19a8c1..164f485f3c3 100644 --- a/source/source_base/module_parallel/test/para_world_mpi_test.sh +++ b/source/source_base/module_parallel/test/para_world_mpi_test.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_para_world_mpi + mpirun -np $i "${1:-./MODULE_BASE_para_world_mpi}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_base/test/CMakeLists.txt b/source/source_base/test/CMakeLists.txt index 16ba949d640..4bff3c97cbd 100644 --- a/source/source_base/test/CMakeLists.txt +++ b/source/source_base/test/CMakeLists.txt @@ -1,5 +1,6 @@ abacus_disable_feature_definitions(__MPI) -install(DIRECTORY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(data) + AddTest( TARGET MODULE_BASE_additional_coverage LIBS parameter base device container @@ -247,7 +248,7 @@ AddTest( SOURCES test_lebedev_laikov.cpp ../ylm.cpp ../math_lebedev_laikov.cpp ) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support) AddTest( TARGET MODULE_BASE_binstream diff --git a/source/source_base/test_parallel/CMakeLists.txt b/source/source_base/test_parallel/CMakeLists.txt index 9bfee1fd637..f2afe5d5674 100644 --- a/source/source_base/test_parallel/CMakeLists.txt +++ b/source/source_base/test_parallel/CMakeLists.txt @@ -16,21 +16,21 @@ AddTest( SOURCES parallel_reduce_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../parallel_common.cpp ../parallel_reduce.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ) -install(FILES parallel_common_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES parallel_global_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES parallel_reduce_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - +abacus_copy_test_files( + parallel_common_test.sh + parallel_global_test.sh + parallel_reduce_test.sh) find_program(BASH bash) add_test(NAME MODULE_BASE_parallel_common_test - COMMAND ${BASH} parallel_common_test.sh + COMMAND ${BASH} parallel_common_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_BASE_parallel_global_test - COMMAND ${BASH} parallel_global_test.sh + COMMAND ${BASH} parallel_global_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_BASE_parallel_reduce_test - COMMAND ${BASH} parallel_reduce_test.sh + COMMAND ${BASH} parallel_reduce_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -47,7 +47,7 @@ AddTest( ) add_test(NAME MODULE_BASE_parallel_device_parallel - COMMAND mpirun -np 4 ./MODULE_BASE_parallel_device + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -58,7 +58,7 @@ AddTest( ) add_test(NAME MODULE_BASE_para_gemm_parallel - COMMAND mpirun -np 4 ./MODULE_BASE_para_gemm + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -75,14 +75,14 @@ AddTest( ) add_test(NAME MODULE_BASE_parallel_domain_grid_parallel - COMMAND mpirun -np 4 ./MODULE_BASE_parallel_domain_grid + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) -install(FILES parallel_2d_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(parallel_2d_test.sh) find_program(BASH bash) add_test(NAME MODULE_BASE_parallel_2d_test_para - COMMAND ${BASH} parallel_2d_test.sh + COMMAND ${BASH} parallel_2d_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -99,8 +99,8 @@ add_test(NAME MODULE_BASE_parallel_2d_test_para LIBS parameter MPI::MPI_CXX ${BLACS_LIB} SOURCES blacs_connector_test.cpp ) - install(FILES blacs_connector_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + abacus_copy_test_files(blacs_connector_test.sh) add_test(NAME MODULE_BASE_blacs_connector_test - COMMAND ${BASH} blacs_connector_test.sh + COMMAND ${BASH} blacs_connector_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_base/test_parallel/blacs_connector_test.sh b/source/source_base/test_parallel/blacs_connector_test.sh index cbf6e13ca0b..af748f9be77 100644 --- a/source/source_base/test_parallel/blacs_connector_test.sh +++ b/source/source_base/test_parallel/blacs_connector_test.sh @@ -9,7 +9,7 @@ do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_blacs_connector + mpirun -np $i "${1:-./MODULE_BASE_blacs_connector}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_base/test_parallel/parallel_2d_test.sh b/source/source_base/test_parallel/parallel_2d_test.sh index 47aadc867ef..76aed5d0d93 100644 --- a/source/source_base/test_parallel/parallel_2d_test.sh +++ b/source/source_base/test_parallel/parallel_2d_test.sh @@ -8,7 +8,7 @@ for i in 2 3 4; do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_parallel_2d_test + mpirun -np $i "${1:-./MODULE_BASE_parallel_2d_test}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_base/test_parallel/parallel_common_test.sh b/source/source_base/test_parallel/parallel_common_test.sh index 9adbcb1f95a..edf25f0b5b6 100644 --- a/source/source_base/test_parallel/parallel_common_test.sh +++ b/source/source_base/test_parallel/parallel_common_test.sh @@ -8,7 +8,7 @@ for i in 3;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_ParaCommon + mpirun -np $i "${1:-./MODULE_BASE_ParaCommon}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_base/test_parallel/parallel_global_test.sh b/source/source_base/test_parallel/parallel_global_test.sh index 37024e3cb85..533804a0209 100644 --- a/source/source_base/test_parallel/parallel_global_test.sh +++ b/source/source_base/test_parallel/parallel_global_test.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_ParaGlobal + mpirun -np $i "${1:-./MODULE_BASE_ParaGlobal}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_base/test_parallel/parallel_reduce_test.sh b/source/source_base/test_parallel/parallel_reduce_test.sh index ec2b46a5836..31fcdec807f 100644 --- a/source/source_base/test_parallel/parallel_reduce_test.sh +++ b/source/source_base/test_parallel/parallel_reduce_test.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_BASE_ParaReduce + mpirun -np $i "${1:-./MODULE_BASE_ParaReduce}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_basis/module_ao/test/CMakeLists.txt b/source/source_basis/module_ao/test/CMakeLists.txt index 0830c465e62..1ea201d92ac 100644 --- a/source/source_basis/module_ao/test/CMakeLists.txt +++ b/source/source_basis/module_ao/test/CMakeLists.txt @@ -41,9 +41,7 @@ list(APPEND depend_files ../../../source_lcao/center2orb.cpp ) -install(DIRECTORY GaAs DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../../../tests) -install(DIRECTORY GaAs DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - +abacus_copy_test_files(GaAs) AddTest( TARGET MODULE_AO_ORB_nonlocal_test @@ -84,12 +82,11 @@ AddTest( LIBS parameter device base ) -install(FILES parallel_orbitals_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(parallel_orbitals_test.sh) find_program(BASH bash) add_test(NAME MODULE_AO_parallel_orbitals_test_para - COMMAND ${BASH} parallel_orbitals_test.sh + COMMAND ${BASH} parallel_orbitals_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) -install(DIRECTORY lcao_H2O DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(DIRECTORY lcao_H2O DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../../../tests) +abacus_copy_test_files(lcao_H2O) diff --git a/source/source_basis/module_ao/test/parallel_orbitals_test.sh b/source/source_basis/module_ao/test/parallel_orbitals_test.sh index acb74791389..660baf0de06 100644 --- a/source/source_basis/module_ao/test/parallel_orbitals_test.sh +++ b/source/source_basis/module_ao/test/parallel_orbitals_test.sh @@ -8,7 +8,7 @@ for i in 2 3 4; do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_AO_parallel_orbitals_test + mpirun -np $i "${1:-./MODULE_AO_parallel_orbitals_test}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_basis/module_pw/test/CMakeLists.txt b/source/source_basis/module_pw/test/CMakeLists.txt index b2306f05250..7986857f20b 100644 --- a/source/source_basis/module_pw/test/CMakeLists.txt +++ b/source/source_basis/module_pw/test/CMakeLists.txt @@ -19,6 +19,10 @@ AddTest( ) add_test(NAME MODULE_PW_pw_test_parallel - COMMAND mpirun -np 3 ./MODULE_PW_pw_test; mpirun -np 4 ./MODULE_PW_pw_test + COMMAND mpirun -np 3 "$" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +add_test(NAME MODULE_PW_pw_test_parallel_4np + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_cell/module_neighlist/test/CMakeLists.txt b/source/source_cell/module_neighlist/test/CMakeLists.txt index d2f6c85845a..4c0ba561f68 100644 --- a/source/source_cell/module_neighlist/test/CMakeLists.txt +++ b/source/source_cell/module_neighlist/test/CMakeLists.txt @@ -68,7 +68,6 @@ if(ENABLE_MPI) PRIVATE parameter base device MPI::MPI_CXX GTest::gtest_main GTest::gmock_main abacus::linalg_libs ) - install(TARGETS MODULE_CELL_NEIGHBOR_mdcell_migrate_mpi DESTINATION ${CMAKE_BINARY_DIR}/tests) add_test(NAME MODULE_CELL_NEIGHBOR_mdcell_migrate_mpi COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 $ @@ -107,7 +106,6 @@ if(ENABLE_MPI) PRIVATE parameter base device Threads::Threads MPI::MPI_CXX GTest::gtest GTest::gmock abacus::linalg_libs ) - install(TARGETS MODULE_CELL_NEIGHBOR_mdcell_reader DESTINATION ${CMAKE_BINARY_DIR}/tests) add_test(NAME MODULE_CELL_NEIGHBOR_mdcell_reader_np4 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 $ diff --git a/source/source_cell/test/CMakeLists.txt b/source/source_cell/test/CMakeLists.txt index 9e2c9998d6a..4ee92a1e6e8 100644 --- a/source/source_cell/test/CMakeLists.txt +++ b/source/source_cell/test/CMakeLists.txt @@ -4,22 +4,15 @@ abacus_disable_feature_definitions(__ROCM) abacus_disable_feature_definitions(__EXX) find_program(BASH bash) -file(COPY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -configure_file(bcast_atom_pseudo_test.sh ${CMAKE_CURRENT_BINARY_DIR}/bcast_atom_pseudo_test.sh COPYONLY) -configure_file(bcast_atom_spec_test.sh ${CMAKE_CURRENT_BINARY_DIR}/bcast_atom_spec_test.sh COPYONLY) -configure_file(parallel_kpoints_test.sh ${CMAKE_CURRENT_BINARY_DIR}/parallel_kpoints_test.sh COPYONLY) -configure_file(klist_test_para.sh ${CMAKE_CURRENT_BINARY_DIR}/klist_test_para.sh COPYONLY) -configure_file(unitcell_test_parallel.sh ${CMAKE_CURRENT_BINARY_DIR}/unitcell_test_parallel.sh COPYONLY) -configure_file(bcast_read_sep_test.sh ${CMAKE_CURRENT_BINARY_DIR}/bcast_read_sep_test.sh COPYONLY) -configure_file(bcast_sep_cell_test.sh ${CMAKE_CURRENT_BINARY_DIR}/bcast_sep_cell_test.sh COPYONLY) -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES bcast_atom_pseudo_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES bcast_atom_spec_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES parallel_kpoints_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES klist_test_para.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES unitcell_test_parallel.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES bcast_read_sep_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES bcast_sep_cell_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files( + support + bcast_atom_pseudo_test.sh + bcast_atom_spec_test.sh + parallel_kpoints_test.sh + klist_test_para.sh + unitcell_test_parallel.sh + bcast_read_sep_test.sh + bcast_sep_cell_test.sh) list(APPEND cell_simple_srcs ../unitcell.cpp @@ -123,7 +116,7 @@ AddTest( ) add_test(NAME MODULE_CELL_klist_test_para4 - COMMAND ${BASH} klist_test_para.sh + COMMAND ${BASH} klist_test_para.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -168,17 +161,17 @@ AddTest( find_program(BASH bash) add_test(NAME MODULE_CELL_bcast_atom_pseudo_test - COMMAND ${BASH} bcast_atom_pseudo_test.sh + COMMAND ${BASH} bcast_atom_pseudo_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_CELL_bcast_atom_spec_test - COMMAND ${BASH} bcast_atom_spec_test.sh + COMMAND ${BASH} bcast_atom_spec_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_CELL_parallel_kpoints_test - COMMAND ${BASH} parallel_kpoints_test.sh + COMMAND ${BASH} parallel_kpoints_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -255,7 +248,7 @@ AddTest( ) add_test(NAME MODULE_CELL_unitcell_test_parallel - COMMAND ${BASH} unitcell_test_parallel.sh + COMMAND ${BASH} unitcell_test_parallel.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -272,7 +265,7 @@ AddTest( ) add_test(NAME MODULE_CELL_read_sep_parallel - COMMAND ${BASH} bcast_read_sep_test.sh + COMMAND ${BASH} bcast_read_sep_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -283,7 +276,7 @@ AddTest( ) add_test(NAME MODULE_CELL_sep_cell_parallel - COMMAND ${BASH} bcast_sep_cell_test.sh + COMMAND ${BASH} bcast_sep_cell_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -300,6 +293,6 @@ AddTest( ) add_test(NAME MODULE_CELL_cif_io_parallel - COMMAND mpirun -np 4 ./MODULE_CELL_cif_io + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_cell/test/bcast_atom_pseudo_test.sh b/source/source_cell/test/bcast_atom_pseudo_test.sh index 708e011e768..c156351f6d6 100644 --- a/source/source_cell/test/bcast_atom_pseudo_test.sh +++ b/source/source_cell/test/bcast_atom_pseudo_test.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_CELL_atom_pseudo + mpirun -np $i "${1:-./MODULE_CELL_atom_pseudo}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_cell/test/bcast_atom_spec_test.sh b/source/source_cell/test/bcast_atom_spec_test.sh index 11bb8b5037f..321a4ef2a3a 100644 --- a/source/source_cell/test/bcast_atom_spec_test.sh +++ b/source/source_cell/test/bcast_atom_spec_test.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_CELL_atom_spec + mpirun -np $i "${1:-./MODULE_CELL_atom_spec}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_cell/test/bcast_read_sep_test.sh b/source/source_cell/test/bcast_read_sep_test.sh index 4a38e4f5e4f..6a2c826a708 100644 --- a/source/source_cell/test/bcast_read_sep_test.sh +++ b/source/source_cell/test/bcast_read_sep_test.sh @@ -8,7 +8,7 @@ for i in 4; do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_CELL_SEP_TEST + mpirun -np $i "${1:-./MODULE_CELL_SEP_TEST}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m" \ "execute UT with $i cores error." diff --git a/source/source_cell/test/bcast_sep_cell_test.sh b/source/source_cell/test/bcast_sep_cell_test.sh index 79689516e39..c4b84bd18d5 100644 --- a/source/source_cell/test/bcast_sep_cell_test.sh +++ b/source/source_cell/test/bcast_sep_cell_test.sh @@ -8,7 +8,7 @@ for i in 4; do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_CELL_SEP_CELL_TEST + mpirun -np $i "${1:-./MODULE_CELL_SEP_CELL_TEST}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m" \ "execute UT with $i cores error." diff --git a/source/source_cell/test/klist_test_para.sh b/source/source_cell/test/klist_test_para.sh index e14d46d5c2a..1dd54e29dee 100644 --- a/source/source_cell/test/klist_test_para.sh +++ b/source/source_cell/test/klist_test_para.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_CELL_klist_test_para1 + mpirun -np $i "${1:-./MODULE_CELL_klist_test_para1}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_cell/test/parallel_kpoints_test.sh b/source/source_cell/test/parallel_kpoints_test.sh index d539990f120..4f39cd462d7 100644 --- a/source/source_cell/test/parallel_kpoints_test.sh +++ b/source/source_cell/test/parallel_kpoints_test.sh @@ -9,7 +9,7 @@ do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_CELL_ParaKpoints + mpirun -np $i "${1:-./MODULE_CELL_ParaKpoints}" if [ $? -ne 0 ]; then echo "TEST in parallel, nprocs=$i failed" exit 1 diff --git a/source/source_cell/test/unitcell_test_parallel.sh b/source/source_cell/test/unitcell_test_parallel.sh index d10b2dc5d34..854d901d953 100644 --- a/source/source_cell/test/unitcell_test_parallel.sh +++ b/source/source_cell/test/unitcell_test_parallel.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_CELL_unitcell_test_para + mpirun -np $i "${1:-./MODULE_CELL_unitcell_test_para}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_cell/test_pw/CMakeLists.txt b/source/source_cell/test_pw/CMakeLists.txt index f5051876918..8bd4f7f0ed9 100644 --- a/source/source_cell/test_pw/CMakeLists.txt +++ b/source/source_cell/test_pw/CMakeLists.txt @@ -4,10 +4,9 @@ abacus_disable_feature_definitions(__ROCM) abacus_disable_feature_definitions(__EXX) abacus_disable_feature_definitions(__LCAO) -file(COPY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -configure_file(unitcell_test_pw_para.sh ${CMAKE_CURRENT_BINARY_DIR}/unitcell_test_pw_para.sh COPYONLY) -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES unitcell_test_pw_para.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files( + support + unitcell_test_pw_para.sh) AddTest( TARGET MODULE_CELL_unitcell_test_pw @@ -23,6 +22,6 @@ AddTest( find_program(BASH bash) add_test(NAME MODULE_CELL_unitcell_test_pw_para - COMMAND ${BASH} unitcell_test_pw_para.sh + COMMAND ${BASH} unitcell_test_pw_para.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_cell/test_pw/unitcell_test_pw_para.sh b/source/source_cell/test_pw/unitcell_test_pw_para.sh index df0ec614df7..722b15e6312 100644 --- a/source/source_cell/test_pw/unitcell_test_pw_para.sh +++ b/source/source_cell/test_pw/unitcell_test_pw_para.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_CELL_unitcell_test_pw + mpirun -np $i "${1:-./MODULE_CELL_unitcell_test_pw}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_esolver/test/CMakeLists.txt b/source/source_esolver/test/CMakeLists.txt index 2b7a04a122c..c422da223a3 100644 --- a/source/source_esolver/test/CMakeLists.txt +++ b/source/source_esolver/test/CMakeLists.txt @@ -14,7 +14,7 @@ if(DEFINED DeePMD_DIR) endif() endif() -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support) AddTest( TARGET MODULE_ESOLVER_esolver_dp_test diff --git a/source/source_estate/module_charge/unittests/CMakeLists.txt b/source/source_estate/module_charge/unittests/CMakeLists.txt index 2068271b92b..ada249002e2 100644 --- a/source/source_estate/module_charge/unittests/CMakeLists.txt +++ b/source/source_estate/module_charge/unittests/CMakeLists.txt @@ -158,7 +158,7 @@ AddTest( ) add_test(NAME MODULE_CHARGE_parallel_4np - COMMAND mpirun -np 4 ./MODULE_CHARGE_parallel; + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_estate/module_dm/unittests/CMakeLists.txt b/source/source_estate/module_dm/unittests/CMakeLists.txt index e0a0ecf561e..b17adebee39 100644 --- a/source/source_estate/module_dm/unittests/CMakeLists.txt +++ b/source/source_estate/module_dm/unittests/CMakeLists.txt @@ -2,7 +2,7 @@ abacus_disable_feature_definitions(__MLALGO) abacus_disable_feature_definitions(__CUDA) abacus_disable_feature_definitions(__ROCM) -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support) if(ENABLE_MPI) AddTest( diff --git a/source/source_estate/test/CMakeLists.txt b/source/source_estate/test/CMakeLists.txt index 9ffbeb4e14e..6a4036fe388 100644 --- a/source/source_estate/test/CMakeLists.txt +++ b/source/source_estate/test/CMakeLists.txt @@ -39,10 +39,7 @@ AddTest( SOURCES test_pot_pcc.cpp ${pcc_test_sources} ) -# Copy at configure time so a plain `make` + `ctest` run finds the data. -# install() only runs during `cmake --install`, which local test runs skip. -file(COPY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support) AddTest( TARGET MODULE_ESTATE_Elecstate_Op_UTs diff --git a/source/source_hamilt/module_hcontainer/test/CMakeLists.txt b/source/source_hamilt/module_hcontainer/test/CMakeLists.txt index 74556680149..02b28fbf0cf 100644 --- a/source/source_hamilt/module_hcontainer/test/CMakeLists.txt +++ b/source/source_hamilt/module_hcontainer/test/CMakeLists.txt @@ -38,10 +38,11 @@ AddTest( ../transfer.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp tmp_mocks.cpp ) -install(FILES parallel_hcontainer_tests.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(parallel_hcontainer_tests.sh) find_program(BASH bash) add_test(NAME MODULE_LCAO_hcontainer_para_test COMMAND ${BASH} parallel_hcontainer_tests.sh + "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -57,7 +58,7 @@ AddTest( ../../../source_basis/module_ao/parallel_orbitals.cpp ) -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support) AddTest( TARGET MODULE_LCAO_hcontainer_add_value_test diff --git a/source/source_hamilt/module_hcontainer/test/parallel_hcontainer_tests.sh b/source/source_hamilt/module_hcontainer/test/parallel_hcontainer_tests.sh index 54f82448672..aae35024ba3 100644 --- a/source/source_hamilt/module_hcontainer/test/parallel_hcontainer_tests.sh +++ b/source/source_hamilt/module_hcontainer/test/parallel_hcontainer_tests.sh @@ -8,7 +8,7 @@ for i in 2 3 4; do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_LCAO_hcontainer_transfer_test + mpirun -np $i "${1:-./MODULE_LCAO_hcontainer_transfer_test}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_hamilt/module_surchem/test/CMakeLists.txt b/source/source_hamilt/module_surchem/test/CMakeLists.txt index b843b7cb6e1..ddd30ce6d42 100644 --- a/source/source_hamilt/module_surchem/test/CMakeLists.txt +++ b/source/source_hamilt/module_surchem/test/CMakeLists.txt @@ -1,6 +1,6 @@ abacus_disable_feature_definitions(__LCAO) abacus_disable_feature_definitions(__LIBXC) -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support) list(APPEND depend_files diff --git a/source/source_hamilt/module_vdw/test/CMakeLists.txt b/source/source_hamilt/module_vdw/test/CMakeLists.txt index 195a5312ce8..fddd34b6816 100644 --- a/source/source_hamilt/module_vdw/test/CMakeLists.txt +++ b/source/source_hamilt/module_vdw/test/CMakeLists.txt @@ -2,9 +2,10 @@ abacus_disable_feature_definitions(__MLALGO) abacus_disable_feature_definitions(__CUDA) abacus_disable_feature_definitions(__ROCM) -install(FILES c6.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES r0.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES r0_zero.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files( + c6.txt + r0.txt + r0_zero.txt) AddTest( TARGET MODULE_HAMILT_vdwTest diff --git a/source/source_hamilt/module_xc/test/CMakeLists.txt b/source/source_hamilt/module_xc/test/CMakeLists.txt index a07e4eb4d7e..82e8188923c 100644 --- a/source/source_hamilt/module_xc/test/CMakeLists.txt +++ b/source/source_hamilt/module_xc/test/CMakeLists.txt @@ -114,7 +114,7 @@ set_tests_properties( PROPERTIES ENVIRONMENT "OMP_NUM_THREADS=1" PROCESSORS 2 - WORKING_DIRECTORY $ + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ) AddTest( diff --git a/source/source_hsolver/test/CMakeLists.txt b/source/source_hsolver/test/CMakeLists.txt index 0cce7c7cd62..f98af874b45 100644 --- a/source/source_hsolver/test/CMakeLists.txt +++ b/source/source_hsolver/test/CMakeLists.txt @@ -130,30 +130,27 @@ if (ENABLE_MPI) target_compile_definitions(MODULE_HSOLVER_LCAO_cusolver PRIVATE __CUDA) endif() endif() -install(FILES H-KPoints-Si2.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES H-GammaOnly-Si2.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES S-KPoints-Si2.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES S-GammaOnly-Si2.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES H-KPoints-Si64.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES H-GammaOnly-Si64.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES S-KPoints-Si64.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES S-GammaOnly-Si64.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -install(FILES GammaOnly-Si2-Solution.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES GammaOnly-Si64-Solution.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES KPoints-Si2-Solution.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES KPoints-Si64-Solution.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -install(FILES diago_cg_parallel_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES diago_david_parallel_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES diago_lcao_parallel_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -install(FILES PEXSI-H-GammaOnly-Si2.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES PEXSI-S-GammaOnly-Si2.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES PEXSI-DM-GammaOnly-Si2.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES diago_pexsi_parallel_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -install(FILES parallel_k2d_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - +abacus_copy_test_files( + H-KPoints-Si2.dat + H-GammaOnly-Si2.dat + S-KPoints-Si2.dat + S-GammaOnly-Si2.dat + H-KPoints-Si64.dat + H-GammaOnly-Si64.dat + S-KPoints-Si64.dat + S-GammaOnly-Si64.dat + GammaOnly-Si2-Solution.dat + GammaOnly-Si64-Solution.dat + KPoints-Si2-Solution.dat + KPoints-Si64-Solution.dat + diago_cg_parallel_test.sh + diago_david_parallel_test.sh + diago_lcao_parallel_test.sh + PEXSI-H-GammaOnly-Si2.dat + PEXSI-S-GammaOnly-Si2.dat + PEXSI-DM-GammaOnly-Si2.dat + diago_pexsi_parallel_test.sh + parallel_k2d_test.sh) if(ENABLE_MPI) if(TARGET ELPA::ELPA) @@ -187,7 +184,7 @@ if(ENABLE_MPI) add_test( NAME MODULE_HSOLVER_para_linear_trans - COMMAND mpirun -np 4 ./MODULE_HSOLVER_linear_trans + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif() @@ -196,24 +193,31 @@ find_program(BASH bash) if (ENABLE_MPI) add_test(NAME MODULE_HSOLVER_cg_parallel COMMAND ${BASH} diago_cg_parallel_test.sh + "$" + "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_HSOLVER_parak2d_test_parallel - COMMAND ${BASH} parallel_k2d_test.sh + COMMAND ${BASH} parallel_k2d_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_test(NAME MODULE_HSOLVER_dav_parallel COMMAND ${BASH} diago_david_parallel_test.sh + "$" + "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) if(ENABLE_LCAO) add_test(NAME MODULE_HSOLVER_LCAO_parallel COMMAND ${BASH} diago_lcao_parallel_test.sh + "$" + "$" + "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) if(ENABLE_PEXSI) add_test(NAME MODULE_HSOLVER_LCAO_PEXSI_parallel - COMMAND ${BASH} diago_pexsi_parallel_test.sh + COMMAND ${BASH} diago_pexsi_parallel_test.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif() diff --git a/source/source_hsolver/test/diago_cg_parallel_test.sh b/source/source_hsolver/test/diago_cg_parallel_test.sh index 6a4831b4b33..6f8b2ce91e1 100644 --- a/source/source_hsolver/test/diago_cg_parallel_test.sh +++ b/source/source_hsolver/test/diago_cg_parallel_test.sh @@ -8,9 +8,9 @@ for i in 6 3 2;do continue fi echo "TEST DIAGO CG in parallel, nprocs=$i" - OMP_NUM_THREADS=1 mpirun -np $i ./MODULE_HSOLVER_cg + OMP_NUM_THREADS=1 mpirun -np $i "${1:-./MODULE_HSOLVER_cg}" e1=$? - OMP_NUM_THREADS=1 mpirun -np $i ./MODULE_HSOLVER_cg_float + OMP_NUM_THREADS=1 mpirun -np $i "${2:-./MODULE_HSOLVER_cg_float}" e2=$? if [[ e1 -ne 0 || e2 -ne 0 ]];then echo -e "\e[1;33m [ FAILED ] \e[0m"\ diff --git a/source/source_hsolver/test/diago_david_parallel_test.sh b/source/source_hsolver/test/diago_david_parallel_test.sh index 4c476369e56..a57507e18a6 100644 --- a/source/source_hsolver/test/diago_david_parallel_test.sh +++ b/source/source_hsolver/test/diago_david_parallel_test.sh @@ -8,9 +8,9 @@ for i in 6 3 2;do continue fi echo "TEST DIAGO davidson in parallel, nprocs=$i" - OMP_NUM_THREADS=1 mpirun -np $i ./MODULE_HSOLVER_dav + OMP_NUM_THREADS=1 mpirun -np $i "${1:-./MODULE_HSOLVER_dav}" e1=$? - OMP_NUM_THREADS=1 mpirun -np $i ./MODULE_HSOLVER_dav_float + OMP_NUM_THREADS=1 mpirun -np $i "${2:-./MODULE_HSOLVER_dav_float}" e2=$? if [[ e1 -ne 0 || e2 -ne 0 ]];then echo -e "\e[1;33m [ FAILED ] \e[0m"\ diff --git a/source/source_hsolver/test/diago_lcao_parallel_test.sh b/source/source_hsolver/test/diago_lcao_parallel_test.sh index 7ec89c28a4d..e7e296ec480 100644 --- a/source/source_hsolver/test/diago_lcao_parallel_test.sh +++ b/source/source_hsolver/test/diago_lcao_parallel_test.sh @@ -8,9 +8,9 @@ for i in 6 3 2;do continue fi echo "TEST DIAGO davidson in parallel, nprocs=$i" - mpirun -np $i ./MODULE_HSOLVER_LCAO - mpirun -np $i ./MODULE_HSOLVER_dav_real - mpirun -np $i ./MODULE_HSOLVER_cg_real + mpirun -np $i "${1:-./MODULE_HSOLVER_LCAO}" + mpirun -np $i "${2:-./MODULE_HSOLVER_dav_real}" + mpirun -np $i "${3:-./MODULE_HSOLVER_cg_real}" if [[ $? != 0 ]];then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_hsolver/test/diago_pexsi_parallel_test.sh b/source/source_hsolver/test/diago_pexsi_parallel_test.sh index 34bdfc48c30..43e1c277107 100644 --- a/source/source_hsolver/test/diago_pexsi_parallel_test.sh +++ b/source/source_hsolver/test/diago_pexsi_parallel_test.sh @@ -8,7 +8,7 @@ for i in 6 3 2;do continue fi echo "TEST DIAGO PEXSI in parallel, nprocs=$i" - mpirun -np $i ./MODULE_HSOLVER_LCAO_PEXSI + mpirun -np $i "${1:-./MODULE_HSOLVER_LCAO_PEXSI}" if [[ $? != 0 ]];then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_hsolver/test/parallel_k2d_test.sh b/source/source_hsolver/test/parallel_k2d_test.sh index 50996ce8ee2..f7ee917ce80 100644 --- a/source/source_hsolver/test/parallel_k2d_test.sh +++ b/source/source_hsolver/test/parallel_k2d_test.sh @@ -8,7 +8,7 @@ for i in 8;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_HSOLVER_parak2d_test + mpirun -np $i "${1:-./MODULE_HSOLVER_parak2d_test}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_io/module_hs/unittests/CMakeLists.txt b/source/source_io/module_hs/unittests/CMakeLists.txt index cab6dedb809..3cc91801afa 100644 --- a/source/source_io/module_hs/unittests/CMakeLists.txt +++ b/source/source_io/module_hs/unittests/CMakeLists.txt @@ -10,7 +10,7 @@ AddTest( add_test( NAME MODULE_IO_hsk_writer_test_parallel - COMMAND mpirun -np 2 ./MODULE_IO_hsk_writer_test + COMMAND mpirun -np 2 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -59,7 +59,7 @@ AddTest( add_test( NAME MODULE_IO_hs_dense_io_test_parallel - COMMAND mpirun -np 2 ./MODULE_IO_hs_dense_io_test + COMMAND mpirun -np 2 "$" --gtest_filter=HsDenseIoSaveMat.BinaryGammaUpperTriangle:HsDenseIoSaveMat.BinaryComplexUpperTriangleMpiReduction:HsDenseIoSaveMat.BinaryAppendCompleteRecordsAndOverwrite WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -78,7 +78,7 @@ AddTest( add_test( NAME MODULE_IO_hsr_writer_test_parallel - COMMAND mpirun -np 2 ./MODULE_IO_hsr_writer_test + COMMAND mpirun -np 2 "$" --gtest_filter=HsrWriterIo.HContainerBinaryMpiGatherWritesCompleteFiles WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_io/test/CMakeLists.txt b/source/source_io/test/CMakeLists.txt index 6cfbecf5089..a11fa9af8ac 100644 --- a/source/source_io/test/CMakeLists.txt +++ b/source/source_io/test/CMakeLists.txt @@ -27,8 +27,9 @@ add_test(NAME MODULE_IO_write_bands_parallel ) set_tests_properties(MODULE_IO_write_bands_parallel PROPERTIES PROCESSORS 4 TIMEOUT 120) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -configure_file(INPUTs ${CMAKE_CURRENT_BINARY_DIR}/INPUTs COPYONLY) +abacus_copy_test_files( + support + INPUTs) AddTest( TARGET MODULE_IO_input_test_para @@ -37,7 +38,7 @@ AddTest( ) add_test(NAME MODULE_IO_input_test_para_4 - COMMAND mpirun -np 4 ./MODULE_IO_input_test_para + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -48,7 +49,7 @@ AddTest( ) add_test(NAME MODULE_IO_read_exit_file_test_para_4 - COMMAND mpirun -np 4 ./MODULE_IO_read_exit_file_test + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -93,10 +94,10 @@ AddTest( SOURCES write_wfc_nao_test.cpp ../module_wf/write_wfc_nao.cpp ../../source_basis/module_ao/parallel_orbitals.cpp ) -configure_file(write_wfc_nao_para.sh ${CMAKE_CURRENT_BINARY_DIR}/write_wfc_nao_para.sh COPYONLY) +abacus_copy_test_files(write_wfc_nao_para.sh) find_program(BASH bash) add_test(NAME MODULE_IO_write_wfc_nao_para - COMMAND ${BASH} write_wfc_nao_para.sh + COMMAND ${BASH} write_wfc_nao_para.sh "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -153,7 +154,7 @@ AddTest( ) add_test(NAME MODULE_IO_read_wfc_pw_test_parallel - COMMAND mpirun -np 4 ./MODULE_IO_read_wfc_pw_test + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -165,7 +166,7 @@ AddTest( ) add_test(NAME MODULE_IO_read_wf2rho_pw_parallel - COMMAND mpirun -np 4 ./MODULE_IO_read_wf2rho_pw_test + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -210,7 +211,7 @@ AddTest( ) add_test(NAME MODULE_IO_orb_io_test_parallel - COMMAND mpirun -np 4 ./MODULE_IO_orb_io_test + COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -223,7 +224,7 @@ AddTest( add_test( NAME MODULE_IO_write_dmk_parallel - COMMAND mpirun -np 2 ./MODULE_IO_write_dmk + COMMAND mpirun -np 2 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -244,7 +245,7 @@ AddTest( add_test( NAME MODULE_IO_read_wfc_nao_test_parallel - COMMAND mpirun -np 2 ./MODULE_IO_read_wfc_nao_test + COMMAND mpirun -np 2 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_io/test/write_wfc_nao_para.sh b/source/source_io/test/write_wfc_nao_para.sh index 752fcd9b5ef..ddc0e8ae70e 100644 --- a/source/source_io/test/write_wfc_nao_para.sh +++ b/source/source_io/test/write_wfc_nao_para.sh @@ -8,7 +8,7 @@ for i in 4;do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_IO_write_wfc_nao + mpirun -np $i "${1:-./MODULE_IO_write_wfc_nao}" if [[ $? -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ "execute UT with $i cores error." diff --git a/source/source_io/test_serial/CMakeLists.txt b/source/source_io/test_serial/CMakeLists.txt index 3238fb743d4..48aeea81a22 100644 --- a/source/source_io/test_serial/CMakeLists.txt +++ b/source/source_io/test_serial/CMakeLists.txt @@ -27,7 +27,8 @@ add_library( ../module_parameter/availability_validator.cpp ) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support) + AddTest( TARGET MODULE_IO_read_input_serial LIBS parameter io_input_serial diff --git a/source/source_lcao/module_deepks/test/CMakeLists.txt b/source/source_lcao/module_deepks/test/CMakeLists.txt index 2ee3e1970c2..31e830889f7 100644 --- a/source/source_lcao/module_deepks/test/CMakeLists.txt +++ b/source/source_lcao/module_deepks/test/CMakeLists.txt @@ -1,4 +1,4 @@ -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support) set(DEEPKS_UT_PP_ORB_DIR "${PROJECT_SOURCE_DIR}/tests/PP_ORB") configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/support/NO_GO_deepks_UT/STRU diff --git a/source/source_lcao/module_operator_lcao/test/CMakeLists.txt b/source/source_lcao/module_operator_lcao/test/CMakeLists.txt index dbd321da8f7..2280bb00c4f 100644 --- a/source/source_lcao/module_operator_lcao/test/CMakeLists.txt +++ b/source/source_lcao/module_operator_lcao/test/CMakeLists.txt @@ -93,10 +93,15 @@ AddTest( tmp_mocks.cpp ../../../source_hamilt/operator.cpp ) -install(FILES parallel_operator_tests.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(parallel_operator_tests.sh) find_program(BASH bash) add_test(NAME MODULE_LCAO_operators_para_test COMMAND ${BASH} parallel_operator_tests.sh + "$" + "$" + "$" + "$" + "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/source/source_lcao/module_operator_lcao/test/parallel_operator_tests.sh b/source/source_lcao/module_operator_lcao/test/parallel_operator_tests.sh index 05ec9eef912..2636680e9fb 100644 --- a/source/source_lcao/module_operator_lcao/test/parallel_operator_tests.sh +++ b/source/source_lcao/module_operator_lcao/test/parallel_operator_tests.sh @@ -12,15 +12,15 @@ for i in 2 3 4; do continue fi echo "TEST in parallel, nprocs=$i" - mpirun -np $i ./MODULE_LCAO_operator_overlap_cd_test + mpirun -np $i "${1:-./MODULE_LCAO_operator_overlap_cd_test}" e1=$? - mpirun -np $i ./MODULE_LCAO_operator_overlap_test + mpirun -np $i "${2:-./MODULE_LCAO_operator_overlap_test}" e2=$? - mpirun -np $i ./MODULE_LCAO_operator_ekinetic_test + mpirun -np $i "${3:-./MODULE_LCAO_operator_ekinetic_test}" e3=$? - mpirun -np $i ./MODULE_LCAO_operator_nonlocal_test + mpirun -np $i "${4:-./MODULE_LCAO_operator_nonlocal_test}" e4=$? - mpirun -np $i ./MODULE_LCAO_operator_T_NL_cd_test + mpirun -np $i "${5:-./MODULE_LCAO_operator_T_NL_cd_test}" e5=$? if [[ $e1 -ne 0 || $e2 -ne 0 || $e3 -ne 0 || $e4 -ne 0 || $e5 -ne 0 ]]; then echo -e "\e[1;33m [ FAILED ] \e[0m"\ diff --git a/source/source_lcao/module_ri/unittests/CMakeLists.txt b/source/source_lcao/module_ri/unittests/CMakeLists.txt index 8ab5affa5f7..f048b70cde5 100644 --- a/source/source_lcao/module_ri/unittests/CMakeLists.txt +++ b/source/source_lcao/module_ri/unittests/CMakeLists.txt @@ -23,5 +23,4 @@ AddTest( LIBS parameter SOURCES test_abfs_vector3_order.cpp ) -file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/support" - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") +abacus_copy_test_files(support) diff --git a/source/source_lcao/module_ri/unittests/support/CMakeLists.txt b/source/source_lcao/module_ri/unittests/support/CMakeLists.txt deleted file mode 100644 index 7e81d4418af..00000000000 --- a/source/source_lcao/module_ri/unittests/support/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/source_psi/test/CMakeLists.txt b/source/source_psi/test/CMakeLists.txt index 79438154d99..2177a5a072b 100644 --- a/source/source_psi/test/CMakeLists.txt +++ b/source/source_psi/test/CMakeLists.txt @@ -21,4 +21,4 @@ AddTest( ) endif() -install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +abacus_copy_test_files(support)