Merge branch 'develop' into collected-small-changes

This commit is contained in:
Axel Kohlmeyer
2023-08-09 00:43:29 -04:00
51 changed files with 806 additions and 304 deletions

View File

@ -1,10 +1,9 @@
########################################
# CMake build for automated testing
# -*- CMake -*- build file for automated testing
# This file is part of LAMMPS
# Created by Axel Kohlmeyer and Richard Berger
########################################
# download and build googletest framework
# download and build googletest framework
# cannot compile googletest anymore with the default GCC on RHEL 7.x
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0))
message(FATAL_ERROR "Need GNU C++ compiler version 6.x or later for unit testing")
@ -36,11 +35,7 @@ endforeach()
# must repeat handling coverage for older CMake
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND ENABLE_COVERAGE)
if(CMAKE_VERSION VERSION_LESS 3.13)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage")
endif()
########################################

View File

@ -1,3 +1,4 @@
# -*- CMake -*- file for testing the c-library interface
add_executable(test_library_open test_library_open.cpp test_main.cpp)
target_link_libraries(test_library_open PRIVATE lammps GTest::GMock)

View File

@ -1,3 +1,4 @@
# -*- CMake -*- file for testing LAMMPS commands
add_executable(test_simple_commands test_simple_commands.cpp)

View File

@ -1,3 +1,4 @@
# -*- CMake -*- file for testing the direct calls to individual C++ classes
add_executable(test_lammps_class test_lammps_class.cpp)
target_link_libraries(test_lammps_class PRIVATE lammps GTest::GMockMain)

View File

@ -1,6 +1,6 @@
# Custom minimal -*- CMake -*- file for libyaml
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.16)
project(libyaml VERSION 0.2.5
DESCRIPTION "LibYAML a YAML parser and emitter library"
LANGUAGES C

View File

@ -1,3 +1,4 @@
# -*- CMake -*- file for tests of classes computing or modifying forces
find_package(YAML)
if(NOT YAML_FOUND)
@ -19,16 +20,7 @@ function(extract_tags out yaml_file)
set(${out} "${TAGS}" PARENT_SCOPE)
endfunction()
if(CMAKE_VERSION VERSION_LESS 3.12)
# adjust so we find Python 3 versions before Python 2 on old systems with old CMake
set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5)
find_package(PythonInterp) # Deprecated since version 3.12
if(PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
endif()
else()
find_package(Python COMPONENTS Interpreter)
endif()
find_package(Python COMPONENTS Interpreter)
if(Python_EXECUTABLE)
add_custom_target(check-tests
${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/check_tests.py
@ -53,10 +45,8 @@ target_link_libraries(style_tests PUBLIC GTest::GMock Yaml::Yaml lammps)
# propagate sanitizer options to test tools
if(ENABLE_SANITIZER AND (NOT (ENABLE_SANITIZER STREQUAL "none")))
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER})
target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER})
endif()
target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER})
target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER})
endif()
# unit test for error stats class
@ -97,7 +87,7 @@ else()
endif()
# tests for molecular systems and related pair styles
file(GLOB MOL_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/mol-pair-*.yaml)
file(GLOB MOL_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/mol-pair-*.yaml)
# cannot test MSM with single precision data
if(FFT_SINGLE)
list(FILTER MOL_PAIR_TESTS EXCLUDE REGEX "msm")
@ -115,7 +105,7 @@ foreach(TEST ${MOL_PAIR_TESTS})
endforeach()
# tests for metal-like atomic systems and related pair styles
file(GLOB ATOMIC_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/atomic-pair-*.yaml)
file(GLOB ATOMIC_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/atomic-pair-*.yaml)
foreach(TEST ${ATOMIC_PAIR_TESTS})
string(REGEX REPLACE "^.*atomic-pair-(.*)\.yaml" "AtomicPairStyle:\\1" TNAME ${TEST})
extract_tags(TEST_TAGS ${TEST})
@ -129,7 +119,7 @@ foreach(TEST ${ATOMIC_PAIR_TESTS})
endforeach()
# tests for Si-like manybody systems and related pair styles
file(GLOB MANYBODY_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/manybody-pair-*.yaml)
file(GLOB MANYBODY_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/manybody-pair-*.yaml)
foreach(TEST ${MANYBODY_PAIR_TESTS})
string(REGEX REPLACE "^.*manybody-pair-(.*)\.yaml" "ManybodyPairStyle:\\1" TNAME ${TEST})
extract_tags(TEST_TAGS ${TEST})
@ -146,7 +136,7 @@ endforeach()
add_executable(test_bond_style test_bond_style.cpp)
target_link_libraries(test_bond_style PRIVATE lammps style_tests)
file(GLOB BOND_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/bond-*.yaml)
file(GLOB BOND_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/bond-*.yaml)
foreach(TEST ${BOND_TESTS})
string(REGEX REPLACE "^.*bond-(.*)\.yaml" "BondStyle:\\1" TNAME ${TEST})
extract_tags(TEST_TAGS ${TEST})
@ -163,7 +153,7 @@ endforeach()
add_executable(test_angle_style test_angle_style.cpp)
target_link_libraries(test_angle_style PRIVATE lammps style_tests)
file(GLOB ANGLE_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/angle-*.yaml)
file(GLOB ANGLE_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/angle-*.yaml)
foreach(TEST ${ANGLE_TESTS})
string(REGEX REPLACE "^.*angle-(.*)\.yaml" "AngleStyle:\\1" TNAME ${TEST})
extract_tags(TEST_TAGS ${TEST})
@ -177,7 +167,7 @@ foreach(TEST ${ANGLE_TESTS})
endforeach()
# kspace style tester, currently uses the pair style tool
file(GLOB KSPACE_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/kspace-*.yaml)
file(GLOB KSPACE_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/kspace-*.yaml)
# cannot test MSM with single precision data
if(FFT_SINGLE)
list(FILTER KSPACE_TESTS EXCLUDE REGEX "msm")
@ -205,7 +195,7 @@ endif()
target_link_libraries(test_fix_timestep PRIVATE lammps style_tests)
# tests for timestep related fixes (time integration, thermostat, force manipulation, constraints/restraints)
file(GLOB FIX_TIMESTEP_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/fix-timestep-*.yaml)
file(GLOB FIX_TIMESTEP_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/fix-timestep-*.yaml)
foreach(TEST ${FIX_TIMESTEP_TESTS})
string(REGEX REPLACE "^.*fix-timestep-(.*)\.yaml" "FixTimestep:\\1" TNAME ${TEST})
extract_tags(TEST_TAGS ${TEST})
@ -226,7 +216,7 @@ endforeach()
add_executable(test_dihedral_style test_dihedral_style.cpp)
target_link_libraries(test_dihedral_style PRIVATE lammps style_tests)
file(GLOB DIHEDRAL_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/dihedral-*.yaml)
file(GLOB DIHEDRAL_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/dihedral-*.yaml)
foreach(TEST ${DIHEDRAL_TESTS})
string(REGEX REPLACE "^.*dihedral-(.*)\.yaml" "DihedralStyle:\\1" TNAME ${TEST})
extract_tags(TEST_TAGS ${TEST})
@ -243,7 +233,7 @@ endforeach()
add_executable(test_improper_style test_improper_style.cpp)
target_link_libraries(test_improper_style PRIVATE lammps style_tests)
file(GLOB IMPROPER_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/improper-*.yaml)
file(GLOB IMPROPER_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/improper-*.yaml)
foreach(TEST ${IMPROPER_TESTS})
string(REGEX REPLACE "^.*improper-(.*)\.yaml" "ImproperStyle:\\1" TNAME ${TEST})
extract_tags(TEST_TAGS ${TEST})

View File

@ -1,3 +1,4 @@
# -*- CMake -*- file for tests of file reading or writing classes and functions in LAMMPS
add_executable(test_atom_styles test_atom_styles.cpp)
target_link_libraries(test_atom_styles PRIVATE lammps GTest::GMock)

View File

@ -612,6 +612,10 @@ TEST_F(FileOperationsTest, read_data_fix)
EXPECT_EQ(lmp->atom->tag[GETIDX(8)], 8);
EXPECT_EQ(lmp->atom->tag[GETIDX(9)], 9);
EXPECT_EQ(lmp->atom->tag[GETIDX(10)], 10);
// clean up
delete_file("test_mol_id_merge.data");
delete_file("test_mol_id.data");
}
int main(int argc, char **argv)

View File

@ -1,3 +1,5 @@
# -*- CMake -*- file for testing the Fortran interface to LAMMPS
include(CheckGeneratorSupport)
if(NOT CMAKE_GENERATOR_SUPPORT_FORTRAN)
message(STATUS "Skipping Tests for the LAMMPS Fortran Module: no Fortran support in build tool")

View File

@ -1,7 +1,8 @@
# Test calling Python from LAMMPS (and importing the LAMMPS module
# inside those functions). This can do an "anonymous" import of symbols
# from the executable, so the shared library is not needed. The
# availability of the PYTHON package is tested for inside the tester.
# -*- CMake -*- file for tests calling Python from LAMMPS (and importing
# the LAMMPS module inside those functions). This can do an "anonymous"
# import of symbols from the executable, so the shared library is not
# needed. The availability of the PYTHON package is tested for inside
# the tester.
set(TEST_INPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR})
@ -11,20 +12,12 @@ if(NOT BUILD_SHARED_LIBS)
return()
endif()
if(CMAKE_VERSION VERSION_LESS 3.12)
find_package(PythonInterp 3.6) # Deprecated since version 3.12
if(PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
endif()
else()
find_package(Python COMPONENTS Interpreter Development)
endif()
find_package(Python 3.6 COMPONENTS Interpreter Development)
if(PKG_PYTHON)
add_executable(test_python_package test_python_package.cpp)
target_link_libraries(test_python_package PRIVATE lammps GTest::GMock)
target_compile_definitions(test_python_package PRIVATE -DTEST_INPUT_FOLDER=${TEST_INPUT_FOLDER})
# this requires CMake 3.12. don't care to add backward compatibility for this.
if(Python_Development_FOUND)
target_compile_definitions(test_python_package PRIVATE -DTEST_HAVE_PYTHON_DEVELOPMENT=1)
target_link_libraries(test_python_package PRIVATE Python::Python)

View File

@ -1,13 +1,8 @@
# -*- CMake -*- file for tests of utily functions and classes in LAMMPS
# we use python 3's subprocess module to run the tools and check the output
if(CMAKE_VERSION VERSION_LESS 3.12)
find_package(PythonInterp 3.5) # Deprecated since version 3.12
if(PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
endif()
else()
find_package(Python 3.5 COMPONENTS Interpreter)
endif()
find_package(Python 3.6 COMPONENTS Interpreter)
get_property(BUILD_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(BUILD_IS_MULTI_CONFIG)
set(LAMMPS_SHELL_EXE_DIR ${CMAKE_BINARY_DIR}/$<CONFIG>)

View File

@ -1,3 +1,4 @@
# -*- CMake -*- file for tests of utily functions and classes in LAMMPS
add_executable(test_tokenizer test_tokenizer.cpp)
target_link_libraries(test_tokenizer PRIVATE lammps GTest::GMockMain)