Merge remote-tracking branch 'github/develop' into fmt_upgrade
This commit is contained in:
@ -1,44 +1,28 @@
|
||||
|
||||
# build LAMMPS plugins, but not on Windows
|
||||
if((NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) AND PKG_PLUGIN)
|
||||
ExternalProject_Add(plugins
|
||||
SOURCE_DIR "${LAMMPS_DIR}/examples/plugins"
|
||||
BINARY_DIR ${CMAKE_BINARY_DIR}/build-plugins
|
||||
INSTALL_DIR ${CMAKE_BINARY_DIR}
|
||||
CMAKE_ARGS ${CMAKE_REQUEST_PIC}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_BYPRODUCTS <BINARY_DIR>/morse2plugin${CMAKE_SHARED_MODULE_SUFFIX}
|
||||
<BINARY_DIR>/nve2plugin${CMAKE_SHARED_MODULE_SUFFIX}
|
||||
<BINARY_DIR>/helloplugin${CMAKE_SHARED_MODULE_SUFFIX}
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
<BINARY_DIR>/morse2plugin${CMAKE_SHARED_MODULE_SUFFIX}
|
||||
<BINARY_DIR>/nve2plugin${CMAKE_SHARED_MODULE_SUFFIX}
|
||||
<BINARY_DIR>/helloplugin${CMAKE_SHARED_MODULE_SUFFIX}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
TEST_COMMAND "")
|
||||
endif()
|
||||
|
||||
add_executable(test_simple_commands test_simple_commands.cpp)
|
||||
if(PKG_PLUGIN)
|
||||
|
||||
# tests for the plugin command require the PLUGIN package and won't work on windows
|
||||
if((NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) AND PKG_PLUGIN)
|
||||
add_subdirectory(${LAMMPS_DIR}/examples/plugins ${CMAKE_BINARY_DIR}/build-plugins)
|
||||
add_dependencies(test_simple_commands plugins)
|
||||
target_compile_definitions(test_simple_commands PRIVATE -DLMP_PLUGIN)
|
||||
endif()
|
||||
target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock GTest::GTest)
|
||||
|
||||
target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME SimpleCommands COMMAND test_simple_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set_tests_properties(SimpleCommands PROPERTIES
|
||||
ENVIRONMENT "LAMMPS_PLUGIN_BIN_DIR=${CMAKE_BINARY_DIR}/build-plugins")
|
||||
|
||||
add_executable(test_lattice_region test_lattice_region.cpp)
|
||||
target_link_libraries(test_lattice_region PRIVATE lammps GTest::GMock GTest::GTest)
|
||||
target_link_libraries(test_lattice_region PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME LatticeRegion COMMAND test_lattice_region WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_executable(test_groups test_groups.cpp)
|
||||
target_link_libraries(test_groups PRIVATE lammps GTest::GMock GTest::GTest)
|
||||
target_link_libraries(test_groups PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME Groups COMMAND test_groups WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_executable(test_variables test_variables.cpp)
|
||||
target_link_libraries(test_variables PRIVATE lammps GTest::GMock GTest::GTest)
|
||||
target_link_libraries(test_variables PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME Variables COMMAND test_variables WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_executable(test_kim_commands test_kim_commands.cpp)
|
||||
@ -49,17 +33,15 @@ if(KIM_EXTRA_UNITTESTS)
|
||||
message(FATAL_ERROR "CURL not found. Enabling KIM extra unit tests requires to have libcurl installed.")
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock GTest::GTest)
|
||||
target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME KimCommands COMMAND test_kim_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_executable(test_reset_ids test_reset_ids.cpp)
|
||||
target_compile_definitions(test_reset_ids PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(test_reset_ids PRIVATE lammps GTest::GMock GTest::GTest)
|
||||
target_link_libraries(test_reset_ids PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME ResetIDs COMMAND test_reset_ids WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if(BUILD_MPI)
|
||||
add_executable(test_mpi_load_balancing test_mpi_load_balancing.cpp)
|
||||
target_link_libraries(test_mpi_load_balancing PRIVATE lammps GTest::GTest GTest::GMock)
|
||||
target_compile_definitions(test_mpi_load_balancing PRIVATE ${TEST_CONFIG_DEFS})
|
||||
add_mpi_test(NAME MPILoadBalancing NUM_PROCS 4 COMMAND $<TARGET_FILE:test_mpi_load_balancing>)
|
||||
endif()
|
||||
add_executable(test_mpi_load_balancing test_mpi_load_balancing.cpp)
|
||||
target_link_libraries(test_mpi_load_balancing PRIVATE lammps GTest::GMock)
|
||||
target_compile_definitions(test_mpi_load_balancing PRIVATE ${TEST_CONFIG_DEFS})
|
||||
add_mpi_test(NAME MPILoadBalancing NUM_PROCS 4 COMMAND $<TARGET_FILE:test_mpi_load_balancing>)
|
||||
|
||||
@ -204,7 +204,7 @@ TEST_F(GroupTest, SelectRestart)
|
||||
command("write_restart group.restart");
|
||||
command("clear");
|
||||
command("read_restart group.restart");
|
||||
unlink("group.restart");
|
||||
platform::unlink("group.restart");
|
||||
END_HIDE_OUTPUT();
|
||||
group = lmp->group;
|
||||
ASSERT_EQ(group->count(group->find("one")), 16);
|
||||
@ -246,7 +246,7 @@ TEST_F(GroupTest, Molecular)
|
||||
ASSERT_DOUBLE_EQ(group->mass(group->find("half")), 40);
|
||||
ASSERT_DOUBLE_EQ(group->mass(group->find("half"), domain->find_region("top")), 10);
|
||||
ASSERT_NEAR(group->charge(group->find("top")), 0, 1.0e-14);
|
||||
ASSERT_DOUBLE_EQ(group->charge(group->find("right"), domain->find_region("top")), 0);
|
||||
ASSERT_NEAR(group->charge(group->find("right"), domain->find_region("top")), 0, 1.0e-14);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal group command.*", command("group three include xxx"););
|
||||
}
|
||||
@ -316,7 +316,7 @@ int main(int argc, char **argv)
|
||||
MPI_Init(&argc, &argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
|
||||
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
std::cout << "Warning: using OpenMPI without exceptions. "
|
||||
"Death tests will be skipped\n";
|
||||
|
||||
|
||||
@ -684,7 +684,7 @@ int main(int argc, char **argv)
|
||||
MPI_Init(&argc, &argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
|
||||
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
std::cout << "Warning: using OpenMPI without exceptions. "
|
||||
"Death tests will be skipped\n";
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#include "lammps.h"
|
||||
#include "lattice.h"
|
||||
#include "region.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@ -631,7 +630,7 @@ int main(int argc, char **argv)
|
||||
MPI_Init(&argc, &argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
|
||||
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
std::cout << "Warning: using OpenMPI without exceptions. "
|
||||
"Death tests will be skipped\n";
|
||||
|
||||
|
||||
@ -686,7 +686,7 @@ int main(int argc, char **argv)
|
||||
MPI_Init(&argc, &argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
|
||||
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
std::cout << "Warning: using OpenMPI without exceptions. "
|
||||
"Death tests will be skipped\n";
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#include "input.h"
|
||||
#include "output.h"
|
||||
#include "update.h"
|
||||
#include "utils.h"
|
||||
#include "variable.h"
|
||||
|
||||
#include "../testing/core.h"
|
||||
@ -217,7 +216,7 @@ TEST_F(SimpleCommandsTest, Quit)
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", command("quit xxx"););
|
||||
|
||||
// the following tests must be skipped with OpenMPI due to using threads
|
||||
if (Info::get_mpi_vendor() == "Open MPI") GTEST_SKIP();
|
||||
if (platform::mpi_vendor() == "Open MPI") GTEST_SKIP();
|
||||
ASSERT_EXIT(command("quit"), ExitedWithCode(0), "");
|
||||
ASSERT_EXIT(command("quit 9"), ExitedWithCode(9), "");
|
||||
}
|
||||
@ -385,7 +384,12 @@ TEST_F(SimpleCommandsTest, Units)
|
||||
#if defined(LMP_PLUGIN)
|
||||
TEST_F(SimpleCommandsTest, Plugin)
|
||||
{
|
||||
std::string loadfmt("plugin load {}plugin.so");
|
||||
const char *bindir = getenv("LAMMPS_PLUGIN_BIN_DIR");
|
||||
const char *config = getenv("CMAKE_CONFIG_TYPE");
|
||||
if (!bindir) GTEST_SKIP();
|
||||
std::string loadfmt = platform::path_join("plugin load ", bindir);
|
||||
if (config) loadfmt = platform::path_join(loadfmt, config);
|
||||
loadfmt = platform::path_join(loadfmt, "{}plugin.so");
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one(fmt::format(loadfmt, "hello"));
|
||||
auto text = ::testing::internal::GetCapturedStdout();
|
||||
@ -396,7 +400,7 @@ TEST_F(SimpleCommandsTest, Plugin)
|
||||
lmp->input->one(fmt::format(loadfmt, "xxx"));
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Open of file xxx.* failed.*"));
|
||||
ASSERT_THAT(text, MatchesRegex(".*Open of file .*xxx.* failed.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one(fmt::format(loadfmt, "nve2"));
|
||||
@ -427,8 +431,7 @@ TEST_F(SimpleCommandsTest, Plugin)
|
||||
lmp->input->one("plugin unload pair nve2");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Ignoring unload of pair style nve2: "
|
||||
"not loaded from a plugin.*"));
|
||||
ASSERT_THAT(text, MatchesRegex(".*Ignoring unload of pair style nve2: not from a plugin.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("plugin unload fix nve2");
|
||||
@ -440,8 +443,7 @@ TEST_F(SimpleCommandsTest, Plugin)
|
||||
lmp->input->one("plugin unload fix nve");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Ignoring unload of fix style nve: "
|
||||
"not loaded from a plugin.*"));
|
||||
ASSERT_THAT(text, MatchesRegex(".*Ignoring unload of fix style nve: not from a plugin.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("plugin list");
|
||||
@ -528,7 +530,7 @@ int main(int argc, char **argv)
|
||||
MPI_Init(&argc, &argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
|
||||
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
std::cout << "Warning: using OpenMPI without exceptions. "
|
||||
"Death tests will be skipped\n";
|
||||
|
||||
|
||||
@ -59,8 +59,8 @@ protected:
|
||||
void TearDown() override
|
||||
{
|
||||
LAMMPSTest::TearDown();
|
||||
unlink("test_variable.file");
|
||||
unlink("test_variable.atomfile");
|
||||
platform::unlink("test_variable.file");
|
||||
platform::unlink("test_variable.atomfile");
|
||||
}
|
||||
|
||||
void atomic_system()
|
||||
@ -165,7 +165,7 @@ TEST_F(VariableTest, CreateDelete)
|
||||
fputs(" ", fp);
|
||||
fclose(fp);
|
||||
ASSERT_THAT(variable->retrieve("file"), StrEq("1"));
|
||||
unlink("MYFILE");
|
||||
platform::unlink("MYFILE");
|
||||
ASSERT_THAT(variable->retrieve("file"), StrEq("0"));
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
@ -317,7 +317,7 @@ TEST_F(VariableTest, Expressions)
|
||||
ASSERT_TRUE(variable->equalstyle(ivar));
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal(ivar), 2.0);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("v_three"), 3.0);
|
||||
ASSERT_FLOAT_EQ(variable->compute_equal("v_four"), MY_PI);
|
||||
ASSERT_NEAR(variable->compute_equal("v_four"), MY_PI,1.0e-14);
|
||||
ASSERT_GE(variable->compute_equal("v_five"), 20210310);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("v_seven"), -1);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("v_eight"), 2.5);
|
||||
@ -517,7 +517,7 @@ int main(int argc, char **argv)
|
||||
MPI_Init(&argc, &argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
|
||||
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
|
||||
std::cout << "Warning: using OpenMPI without exceptions. "
|
||||
"Death tests will be skipped\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user