Merge remote-tracking branch 'lammps/develop' into electrode
This commit is contained in:
@ -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()
|
||||
|
||||
########################################
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -26,10 +26,11 @@ protected:
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-var", "x", "2", "-var", "zpos", "1.5"};
|
||||
"-var", "x", "2", "-var", "zpos", "1.5",
|
||||
nullptr};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
|
||||
@ -29,10 +29,11 @@ protected:
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none",
|
||||
"-echo", "screen", "-nocite",
|
||||
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER)};
|
||||
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER),
|
||||
nullptr};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
|
||||
@ -64,9 +64,9 @@ static void callback(void *handle, step_t timestep, int nlocal, tag_t *, double
|
||||
|
||||
TEST(lammps_external, callback)
|
||||
{
|
||||
const char *args[] = {"liblammps", "-log", "none", "-nocite"};
|
||||
const char *args[] = {"liblammps", "-log", "none", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *handle = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
@ -131,9 +131,9 @@ TEST(lammps_external, callback)
|
||||
|
||||
TEST(lammps_external, array)
|
||||
{
|
||||
const char *args[] = {"liblammps", "-log", "none", "-nocite"};
|
||||
const char *args[] = {"liblammps", "-log", "none", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *handle = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
|
||||
@ -34,9 +34,9 @@ TEST(MPI, global_box)
|
||||
int boxflag;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
|
||||
lammps_command(lmp, "units lj");
|
||||
lammps_command(lmp, "atom_style atomic");
|
||||
@ -77,9 +77,9 @@ TEST(MPI, sub_box)
|
||||
int boxflag;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
|
||||
lammps_command(lmp, "units lj");
|
||||
lammps_command(lmp, "atom_style atomic");
|
||||
@ -143,9 +143,9 @@ TEST(MPI, split_comm)
|
||||
|
||||
MPI_Comm_split(MPI_COMM_WORLD, color, key, &newcomm);
|
||||
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
void *lmp = lammps_open(argc, argv, newcomm, nullptr);
|
||||
lammps_command(lmp, "units lj");
|
||||
lammps_command(lmp, "atom_style atomic");
|
||||
@ -173,9 +173,9 @@ TEST(MPI, multi_partition)
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &me);
|
||||
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-partition", "4x1",
|
||||
"-echo", "screen", "-nocite", "-in", "none"};
|
||||
"-echo", "screen", "-nocite", "-in", "none", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
|
||||
|
||||
lammps_command(lmp, "units lj");
|
||||
@ -205,9 +205,9 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {testbinary, "-log", "none", "-echo", "screen", "-nocite"};
|
||||
const char *args[] = {testbinary, "-log", "none", "-echo", "screen", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
|
||||
InitSystem();
|
||||
|
||||
@ -39,9 +39,9 @@ TEST(lammps_open, null_args)
|
||||
|
||||
TEST(lammps_open, with_args)
|
||||
{
|
||||
const char *args[] = {"liblammps", "-log", "none", "-nocite"};
|
||||
const char *args[] = {"liblammps", "-log", "none", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
// MPI is already initialized
|
||||
MPI_Comm mycomm;
|
||||
@ -78,9 +78,9 @@ TEST(lammps_open, with_args)
|
||||
TEST(lammps_open, with_kokkos)
|
||||
{
|
||||
if (!LAMMPS_NS::LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP();
|
||||
const char *args[] = {"liblammps", "-k", "on", "t", "2", "-sf", "kk", "-log", "none"};
|
||||
const char *args[] = {"liblammps", "-k", "on", "t", "2", "-sf", "kk", "-log", "none", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *alt_ptr;
|
||||
@ -108,9 +108,9 @@ TEST(lammps_open, with_kokkos)
|
||||
|
||||
TEST(lammps_open_no_mpi, no_screen)
|
||||
{
|
||||
const char *args[] = {"liblammps", "-log", "none", "-screen", "none", "-nocite"};
|
||||
const char *args[] = {"liblammps", "-log", "none", "-screen", "none", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *alt_ptr;
|
||||
@ -139,9 +139,9 @@ TEST(lammps_open_no_mpi, with_omp)
|
||||
{
|
||||
if (!LAMMPS_NS::LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
|
||||
const char *args[] = {"liblammps", "-pk", "omp", "2", "neigh", "no",
|
||||
"-sf", "omp", "-log", "none", "-nocite"};
|
||||
"-sf", "omp", "-log", "none", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *alt_ptr;
|
||||
@ -201,9 +201,9 @@ TEST(lammps_open_fortran, no_args)
|
||||
|
||||
TEST(lammps_open_no_mpi, lammps_error)
|
||||
{
|
||||
const char *args[] = {"liblammps", "-log", "none", "-nocite"};
|
||||
const char *args[] = {"liblammps", "-log", "none", "-nocite", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *alt_ptr;
|
||||
|
||||
@ -33,10 +33,11 @@ protected:
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none",
|
||||
"-echo", "screen", "-nocite",
|
||||
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER)};
|
||||
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER),
|
||||
nullptr};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
@ -551,10 +552,10 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite", nullptr};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
@ -632,10 +633,10 @@ TEST(SystemSettings, kokkos)
|
||||
|
||||
// clang-format off
|
||||
const char *args[] = {"SystemSettings", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
"-k", "on", "t", "4", "-sf", "kk", nullptr};
|
||||
// clang-format on
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *lmp = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
|
||||
@ -32,10 +32,11 @@ protected:
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none",
|
||||
"-echo", "screen", "-nocite",
|
||||
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER)};
|
||||
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER),
|
||||
nullptr};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# -*- CMake -*- file for testing LAMMPS commands
|
||||
|
||||
add_executable(test_simple_commands test_simple_commands.cpp)
|
||||
|
||||
|
||||
@ -33,11 +33,9 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {testbinary, "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {testbinary, "-log", "none", "-echo", "screen", "-nocite"};
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
InitSystem();
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
@ -213,8 +213,11 @@ TEST_F(SimpleCommandsTest, Quit)
|
||||
END_HIDE_OUTPUT();
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", command("quit xxx"););
|
||||
|
||||
// the following tests must be skipped with OpenMPI due to using threads
|
||||
// the following tests must be skipped with OpenMPI or MPICH 4.1 and later due to using threads
|
||||
if (platform::mpi_vendor() == "Open MPI") GTEST_SKIP();
|
||||
#if defined(MPICH_NUMVERSION)
|
||||
if (MPICH_NUMVERSION >= 40100000) GTEST_SKIP();
|
||||
#endif
|
||||
ASSERT_EXIT(command("quit"), ExitedWithCode(0), "");
|
||||
ASSERT_EXIT(command("quit 9"), ExitedWithCode(9), "");
|
||||
}
|
||||
|
||||
@ -282,6 +282,13 @@ TEST_F(VariableTest, AtomicSystem)
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("v_rgsum"), 3.75);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("v_sum[1]"), 1.25);
|
||||
|
||||
// check handling of immediate variables
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("f_press[1]"), 0.0);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("c_press"), 0.0);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("c_press[2]"), 0.0);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("1.5+3.25"), 4.75);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("-2.5*1.5"), -3.75);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
||||
command("variable one atom x"););
|
||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
||||
@ -294,6 +301,8 @@ TEST_F(VariableTest, AtomicSystem)
|
||||
variable->compute_equal("v_self"););
|
||||
TEST_FAILURE(".*ERROR: Variable sum2: Inconsistent lengths in vector-style variable.*",
|
||||
variable->compute_equal("max(v_sum2)"););
|
||||
TEST_FAILURE("ERROR: Mismatched fix in variable formula.*",
|
||||
variable->compute_equal("f_press"););
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, Expressions)
|
||||
@ -391,6 +400,8 @@ TEST_F(VariableTest, Functions)
|
||||
command("variable ten2 equal asin(-1.0)+acos(0.0)");
|
||||
command("variable ten3 equal floor(100*random(0.2,0.8,v_seed)+1)");
|
||||
command("variable ten4 equal extract_setting(world_size)");
|
||||
command("variable ten5 equal ternary(v_one,1.1,-2.2)");
|
||||
command("variable ten6 equal ternary(${one}==2.0,v_nine,v_ten)");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_GT(variable->compute_equal(variable->find("two")), 0.99);
|
||||
@ -405,6 +416,8 @@ TEST_F(VariableTest, Functions)
|
||||
ASSERT_GT(variable->compute_equal(variable->find("ten3")), 19);
|
||||
ASSERT_LT(variable->compute_equal(variable->find("ten3")), 81);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal(variable->find("ten4")), 1);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal(variable->find("ten5")), 1.1);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal(variable->find("ten6")), 3);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Variable four: Invalid syntax in variable formula.*",
|
||||
command("print \"${four}\""););
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include <mpi.h>
|
||||
#include <string>
|
||||
|
||||
#include "../testing/utils.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
const char *demo_input[] = {"region box block 0 $x 0 2 0 2", "create_box 1 box",
|
||||
@ -21,9 +22,9 @@ protected:
|
||||
LAMMPS *lmp;
|
||||
Input_commands()
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
const char * args[] = {"LAMMPS_test", nullptr};
|
||||
char ** argv = (char**)args;
|
||||
int argc = 1;
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
@ -33,13 +34,11 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-var", "zpos", "1.5", "-var", "x", "2"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-var", "zpos", "1.5", "-var", "x", "2"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0, 8).c_str(), "LAMMPS (");
|
||||
}
|
||||
|
||||
@ -21,9 +21,9 @@ protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_plain() : lmp(nullptr)
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
const char * args[] = {"LAMMPS_test", nullptr};
|
||||
char ** argv = (char**)args;
|
||||
int argc = 1;
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
@ -34,12 +34,10 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "both", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-echo", "both", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
}
|
||||
@ -159,9 +157,9 @@ protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_omp() : lmp(nullptr)
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
const char * args[] = {"LAMMPS_test", nullptr};
|
||||
char ** argv = (char**)args;
|
||||
int argc = 1;
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
@ -172,15 +170,13 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-screen", "none", "-echo", "screen",
|
||||
"-pk", "omp", "2", "neigh", "yes", "-sf", "omp"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-screen", "none", "-echo", "screen",
|
||||
"-pk", "omp", "2", "neigh", "yes", "-sf", "omp"};
|
||||
|
||||
// only run this test fixture with omp suffix if OPENMP package is installed
|
||||
|
||||
if (LAMMPS::is_installed_pkg("OPENMP"))
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
else
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -242,9 +238,9 @@ protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_kokkos() : lmp(nullptr)
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
const char * args[] = {"LAMMPS_test", nullptr};
|
||||
char ** argv = (char**)args;
|
||||
int argc = 1;
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
@ -255,15 +251,13 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "none", "-screen", "none",
|
||||
"-k", "on", "t", "1", "-sf", "kk"};
|
||||
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-echo", "none", "-screen", "none",
|
||||
"-k", "on", "t", "1", "-sf", "kk"};
|
||||
if (Info::has_accelerator_feature("KOKKOS", "api", "openmp")) args[10] = "2";
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
if (LAMMPS::is_installed_pkg("KOKKOS")) {
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
::testing::internal::GetCapturedStdout();
|
||||
} else
|
||||
GTEST_SKIP();
|
||||
@ -333,12 +327,10 @@ TEST(LAMMPS_init, OpenMP)
|
||||
fputs("\n", fp);
|
||||
fclose(fp);
|
||||
|
||||
const char *args[] = {"LAMMPS_init", "-in", "in.lammps_empty", "-log", "none", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"LAMMPS_init", "-in", "in.lammps_empty", "-log", "none", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
LAMMPS *lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, ContainsRegex(".*using 2 OpenMP thread.*per MPI task.*"));
|
||||
|
||||
@ -366,12 +358,10 @@ TEST(LAMMPS_init, NoOpenMP)
|
||||
fclose(fp);
|
||||
platform::unsetenv("OMP_NUM_THREADS");
|
||||
|
||||
const char *args[] = {"LAMMPS_init", "-in", "in.lammps_class_noomp", "-log", "none", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"LAMMPS_init", "-in", "in.lammps_class_noomp", "-log", "none", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
LAMMPS *lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, ContainsRegex(
|
||||
".*OMP_NUM_THREADS environment is not set.*Defaulting to 1 thread.*"));
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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})
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "angle.h"
|
||||
#include "atom.h"
|
||||
#include "compute.h"
|
||||
#include "exceptions.h"
|
||||
#include "fmt/format.h"
|
||||
#include "force.h"
|
||||
#include "info.h"
|
||||
@ -59,11 +60,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
|
||||
LAMMPS *init_lammps(LAMMPS::argv &args, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
@ -90,7 +91,21 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new
|
||||
|
||||
// utility lambdas to improve readability
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line);
|
||||
try {
|
||||
lmp->input->one(line);
|
||||
} catch (LAMMPSAbortException &ae) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", ae.what());
|
||||
exit(2);
|
||||
} catch (LAMMPSException &e) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", e.what());
|
||||
exit(3);
|
||||
} catch (fmt::format_error &fe) {
|
||||
fprintf(stderr, "fmt::format_error: %s\n", fe.what());
|
||||
exit(4);
|
||||
} catch (std::exception &e) {
|
||||
fprintf(stderr, "General exception: %s\n", e.what());
|
||||
exit(5);
|
||||
}
|
||||
};
|
||||
auto parse_input_script = [&](const std::string &filename) {
|
||||
lmp->input->file(filename.c_str());
|
||||
@ -211,11 +226,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
LAMMPS *lmp = init_lammps(args, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
@ -303,13 +316,10 @@ TEST(AngleStyle, plain)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -358,7 +368,7 @@ TEST(AngleStyle, plain)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
@ -422,14 +432,11 @@ TEST(AngleStyle, omp)
|
||||
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -482,7 +489,7 @@ TEST(AngleStyle, omp)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
@ -525,14 +532,11 @@ TEST(AngleStyle, single)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
// create a LAMMPS instance with standard settings to detect the number of atom types
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
LAMMPS *lmp = init_lammps(args, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!lmp) {
|
||||
@ -672,13 +676,10 @@ TEST(AngleStyle, extract)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!lmp) {
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "atom.h"
|
||||
#include "bond.h"
|
||||
#include "compute.h"
|
||||
#include "exceptions.h"
|
||||
#include "fmt/format.h"
|
||||
#include "force.h"
|
||||
#include "info.h"
|
||||
@ -59,11 +60,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
|
||||
LAMMPS *init_lammps(LAMMPS::argv &args, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
@ -90,7 +91,21 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new
|
||||
|
||||
// utility lambdas to improve readability
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line);
|
||||
try {
|
||||
lmp->input->one(line);
|
||||
} catch (LAMMPSAbortException &ae) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", ae.what());
|
||||
exit(2);
|
||||
} catch (LAMMPSException &e) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", e.what());
|
||||
exit(3);
|
||||
} catch (fmt::format_error &fe) {
|
||||
fprintf(stderr, "fmt::format_error: %s\n", fe.what());
|
||||
exit(4);
|
||||
} catch (std::exception &e) {
|
||||
fprintf(stderr, "General exception: %s\n", e.what());
|
||||
exit(5);
|
||||
}
|
||||
};
|
||||
auto parse_input_script = [&](const std::string &filename) {
|
||||
lmp->input->file(filename.c_str());
|
||||
@ -211,11 +226,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
LAMMPS *lmp = init_lammps(args, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
@ -303,13 +316,10 @@ TEST(BondStyle, plain)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -358,7 +368,7 @@ TEST(BondStyle, plain)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
@ -424,14 +434,11 @@ TEST(BondStyle, omp)
|
||||
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -484,7 +491,7 @@ TEST(BondStyle, omp)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
@ -527,14 +534,11 @@ TEST(BondStyle, single)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
// create a LAMMPS instance with standard settings to detect the number of atom types
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
LAMMPS *lmp = init_lammps(args, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!lmp) {
|
||||
@ -785,13 +789,10 @@ TEST(BondStyle, extract)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!lmp) {
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "atom.h"
|
||||
#include "compute.h"
|
||||
#include "dihedral.h"
|
||||
#include "exceptions.h"
|
||||
#include "fmt/format.h"
|
||||
#include "force.h"
|
||||
#include "info.h"
|
||||
@ -59,11 +60,9 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
|
||||
LAMMPS *init_lammps(LAMMPS::argv &args, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
LAMMPS *lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
@ -90,7 +89,21 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new
|
||||
|
||||
// utility lambdas to improve readability
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line);
|
||||
try {
|
||||
lmp->input->one(line);
|
||||
} catch (LAMMPSAbortException &ae) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", ae.what());
|
||||
exit(2);
|
||||
} catch (LAMMPSException &e) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", e.what());
|
||||
exit(3);
|
||||
} catch (fmt::format_error &fe) {
|
||||
fprintf(stderr, "fmt::format_error: %s\n", fe.what());
|
||||
exit(4);
|
||||
} catch (std::exception &e) {
|
||||
fprintf(stderr, "General exception: %s\n", e.what());
|
||||
exit(5);
|
||||
}
|
||||
};
|
||||
auto parse_input_script = [&](const std::string &filename) {
|
||||
lmp->input->file(filename.c_str());
|
||||
@ -220,11 +233,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
LAMMPS *lmp = init_lammps(args, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
@ -306,13 +317,10 @@ TEST(DihedralStyle, plain)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -361,7 +369,7 @@ TEST(DihedralStyle, plain)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
@ -427,14 +435,11 @@ TEST(DihedralStyle, omp)
|
||||
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -488,7 +493,7 @@ TEST(DihedralStyle, omp)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
|
||||
@ -61,11 +61,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool use_respa = false)
|
||||
LAMMPS *init_lammps(LAMMPS::argv & args, const TestConfig &cfg, const bool use_respa = false)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
@ -169,11 +169,8 @@ void restart_lammps(LAMMPS *lmp, const TestConfig &cfg, bool use_rmass, bool use
|
||||
void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"FixIntegrate", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
LAMMPS::argv args = {"FixIntegrate", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
LAMMPS *lmp = init_lammps(args, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
@ -252,13 +249,10 @@ TEST(FixTimestep, plain)
|
||||
if (test_config.skip_tests.count("static")) GTEST_SKIP();
|
||||
#endif
|
||||
|
||||
const char *args[] = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
LAMMPS *lmp = init_lammps(args, test_config);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
@ -420,7 +414,7 @@ TEST(FixTimestep, plain)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = init_lammps(argc, argv, test_config, true);
|
||||
lmp = init_lammps(args, test_config, true);
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
@ -554,14 +548,12 @@ TEST(FixTimestep, omp)
|
||||
if (test_config.skip_tests.count("static")) GTEST_SKIP();
|
||||
#endif
|
||||
|
||||
const char *args[] = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
LAMMPS::argv args = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
LAMMPS *lmp = init_lammps(args, test_config);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
@ -723,7 +715,7 @@ TEST(FixTimestep, omp)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = init_lammps(argc, argv, test_config, true);
|
||||
lmp = init_lammps(args, test_config, true);
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
#include "atom.h"
|
||||
#include "compute.h"
|
||||
#include "exceptions.h"
|
||||
#include "fmt/format.h"
|
||||
#include "force.h"
|
||||
#include "improper.h"
|
||||
@ -59,11 +60,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
|
||||
LAMMPS *init_lammps(LAMMPS::argv &args, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
@ -90,7 +91,21 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new
|
||||
|
||||
// utility lambdas to improve readability
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line);
|
||||
try {
|
||||
lmp->input->one(line);
|
||||
} catch (LAMMPSAbortException &ae) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", ae.what());
|
||||
exit(2);
|
||||
} catch (LAMMPSException &e) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", e.what());
|
||||
exit(3);
|
||||
} catch (fmt::format_error &fe) {
|
||||
fprintf(stderr, "fmt::format_error: %s\n", fe.what());
|
||||
exit(4);
|
||||
} catch (std::exception &e) {
|
||||
fprintf(stderr, "General exception: %s\n", e.what());
|
||||
exit(5);
|
||||
}
|
||||
};
|
||||
auto parse_input_script = [&](const std::string &filename) {
|
||||
lmp->input->file(filename.c_str());
|
||||
@ -211,11 +226,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
LAMMPS *lmp = init_lammps(args, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
@ -297,13 +310,10 @@ TEST(ImproperStyle, plain)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -352,7 +362,7 @@ TEST(ImproperStyle, plain)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
@ -418,14 +428,11 @@ TEST(ImproperStyle, omp)
|
||||
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -479,7 +486,7 @@ TEST(ImproperStyle, omp)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "atom.h"
|
||||
#include "compute.h"
|
||||
#include "domain.h"
|
||||
#include "exceptions.h"
|
||||
#include "force.h"
|
||||
#include "info.h"
|
||||
#include "input.h"
|
||||
@ -61,11 +62,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
|
||||
LAMMPS *init_lammps(LAMMPS::argv &args, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
@ -92,8 +93,23 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new
|
||||
|
||||
// utility lambdas to improve readability
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line);
|
||||
try {
|
||||
lmp->input->one(line);
|
||||
} catch (LAMMPSAbortException &ae) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", ae.what());
|
||||
exit(2);
|
||||
} catch (LAMMPSException &e) {
|
||||
fprintf(stderr, "LAMMPS Error: %s\n", e.what());
|
||||
exit(3);
|
||||
} catch (fmt::format_error &fe) {
|
||||
fprintf(stderr, "fmt::format_error: %s\n", fe.what());
|
||||
exit(4);
|
||||
} catch (std::exception &e) {
|
||||
fprintf(stderr, "General exception: %s\n", e.what());
|
||||
exit(5);
|
||||
}
|
||||
};
|
||||
|
||||
auto parse_input_script = [&](const std::string &filename) {
|
||||
lmp->input->file(filename.c_str());
|
||||
};
|
||||
@ -225,11 +241,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
LAMMPS *lmp = init_lammps(args, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
@ -323,13 +337,10 @@ TEST(PairStyle, plain)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -388,7 +399,7 @@ TEST(PairStyle, plain)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton pair is forced to be on
|
||||
@ -469,7 +480,7 @@ TEST(PairStyle, plain)
|
||||
if (pair->respa_enable) {
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
lmp->input->one("run_style respa 2 1 inner 1 4.8 5.5 outer 2");
|
||||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
@ -501,17 +512,14 @@ TEST(PairStyle, omp)
|
||||
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
// cannot run dpd styles with more than 1 thread due to using multiple pRNGs
|
||||
if (utils::strmatch(test_config.pair_style, "^dpd")) args[8] = "1";
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -570,7 +578,7 @@ TEST(PairStyle, omp)
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
pair = lmp->force->pair;
|
||||
@ -626,8 +634,8 @@ TEST(PairStyle, kokkos_omp)
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
|
||||
// cannot run dpd styles in plain or hybrid with more than 1 thread due to using multiple pRNGs
|
||||
if (utils::strmatch(test_config.pair_style, "^dpd") ||
|
||||
@ -642,11 +650,8 @@ TEST(PairStyle, kokkos_omp)
|
||||
utils::strmatch(test_config.pair_style, " pace"))
|
||||
args[9] = "1";
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -704,7 +709,7 @@ TEST(PairStyle, kokkos_omp)
|
||||
if (lmp->force->newton_pair == 0) {
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
pair = lmp->force->pair;
|
||||
@ -767,22 +772,19 @@ TEST(PairStyle, gpu)
|
||||
(!Info::has_fft_single_support()))
|
||||
GTEST_SKIP();
|
||||
|
||||
const char *args_neigh[] = {"PairStyle", "-log", "none", "-echo",
|
||||
"screen", "-nocite", "-sf", "gpu"};
|
||||
const char *args_noneigh[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf",
|
||||
"gpu", "-pk", "gpu", "0", "neigh", "no"};
|
||||
|
||||
char **argv = (char **)args_neigh;
|
||||
int argc = sizeof(args_neigh) / sizeof(char *);
|
||||
LAMMPS::argv args_neigh = {"PairStyle", "-log", "none", "-echo",
|
||||
"screen", "-nocite", "-sf", "gpu"};
|
||||
LAMMPS::argv args_noneigh = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf",
|
||||
"gpu", "-pk", "gpu", "0", "neigh", "no"};
|
||||
LAMMPS::argv args = args_neigh;
|
||||
|
||||
// cannot use GPU neighbor list with hybrid pair style (yet)
|
||||
if (test_config.pair_style.substr(0, 6) == "hybrid") {
|
||||
argv = (char **)args_noneigh;
|
||||
argc = sizeof(args_noneigh) / sizeof(char *);
|
||||
args = args_noneigh;
|
||||
}
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, false);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, false);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -854,18 +856,15 @@ TEST(PairStyle, intel)
|
||||
if (!LAMMPS::is_installed_pkg("INTEL")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "intel", "0", "mode", "double", "omp",
|
||||
"4", "lrt", "no", "-sf", "intel"};
|
||||
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "intel", "0", "mode", "double", "omp",
|
||||
"4", "lrt", "no", "-sf", "intel"};
|
||||
|
||||
// cannot use more than 1 thread for dpd styles due to pRNG
|
||||
if (utils::strmatch(test_config.pair_style, "^dpd")) args[12] = "1";
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -942,13 +941,10 @@ TEST(PairStyle, opt)
|
||||
if (!LAMMPS::is_installed_pkg("OPT")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf", "opt"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf", "opt"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
LAMMPS *lmp = init_lammps(args, test_config);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
@ -1025,17 +1021,14 @@ TEST(PairStyle, single)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
// need to add this dependency
|
||||
test_config.prerequisites.emplace_back("atom", "full");
|
||||
|
||||
// create a LAMMPS instance with standard settings to detect the number of atom types
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
LAMMPS *lmp = init_lammps(args, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!lmp) {
|
||||
@ -1276,13 +1269,10 @@ TEST(PairStyle, extract)
|
||||
{
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!lmp) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
---
|
||||
lammps_version: 23 Jun 2022
|
||||
date_generated: Thu Jul 7 09:00:39 2022
|
||||
epsilon: 2e-13
|
||||
epsilon: 1e-12
|
||||
skip_tests:
|
||||
prerequisites: ! |
|
||||
atom full
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
---
|
||||
lammps_version: 17 Feb 2022
|
||||
date_generated: Fri Mar 18 22:17:31 2022
|
||||
epsilon: 5e-12
|
||||
epsilon: 7.5e-12
|
||||
skip_tests:
|
||||
prerequisites: ! |
|
||||
atom full
|
||||
|
||||
@ -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)
|
||||
@ -40,6 +41,8 @@ set_tests_properties(TextFileReader PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${
|
||||
add_executable(test_file_operations test_file_operations.cpp)
|
||||
target_link_libraries(test_file_operations PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME FileOperations COMMAND test_file_operations)
|
||||
# try to mitigate possible OpenMPI bug
|
||||
set_tests_properties(TextFileReader PROPERTIES ENVIRONMENT "OMPI_MCA_sharedfp=\"^sm\"")
|
||||
|
||||
add_executable(test_dump_atom test_dump_atom.cpp)
|
||||
target_link_libraries(test_dump_atom PRIVATE lammps GTest::GMock)
|
||||
|
||||
@ -533,7 +533,7 @@ TEST_F(AtomStyleTest, atomic)
|
||||
ASSERT_NE(lmp->atom->mass_setflag, nullptr);
|
||||
ASSERT_NE(lmp->atom->sametag, nullptr);
|
||||
ASSERT_EQ(lmp->atom->map_style, Atom::MAP_HASH);
|
||||
ASSERT_EQ(lmp->atom->map_user, 2);
|
||||
ASSERT_EQ(lmp->atom->map_user, Atom::MAP_HASH);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 4);
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("pair_coeff * *");
|
||||
@ -587,7 +587,7 @@ TEST_F(AtomStyleTest, atomic)
|
||||
ASSERT_EQ(lmp->atom->mass_setflag[1], 1);
|
||||
ASSERT_EQ(lmp->atom->mass_setflag[2], 1);
|
||||
ASSERT_EQ(lmp->atom->map_style, Atom::MAP_ARRAY);
|
||||
ASSERT_EQ(lmp->atom->map_user, 1);
|
||||
ASSERT_EQ(lmp->atom->map_user, Atom::MAP_ARRAY);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 4);
|
||||
ASSERT_EQ(lmp->atom->tag_consecutive(), 1);
|
||||
|
||||
@ -597,6 +597,7 @@ TEST_F(AtomStyleTest, atomic)
|
||||
command("delete_atoms group two compress no");
|
||||
command("write_restart test_atom_styles.restart");
|
||||
command("clear");
|
||||
command("atom_modify map hash");
|
||||
command("read_restart test_atom_styles.restart");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic"));
|
||||
@ -629,8 +630,8 @@ TEST_F(AtomStyleTest, atomic)
|
||||
EXPECT_NEAR(lmp->atom->mass[2], 2.4, EPSILON);
|
||||
ASSERT_EQ(lmp->atom->mass_setflag[1], 1);
|
||||
ASSERT_EQ(lmp->atom->mass_setflag[2], 1);
|
||||
ASSERT_EQ(lmp->atom->map_style, Atom::MAP_ARRAY);
|
||||
ASSERT_EQ(lmp->atom->map_user, 1);
|
||||
ASSERT_EQ(lmp->atom->map_style, Atom::MAP_HASH);
|
||||
ASSERT_EQ(lmp->atom->map_user, Atom::MAP_HASH);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 3);
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset_atom_ids");
|
||||
@ -4561,8 +4562,8 @@ TEST_F(AtomStyleTest, property_atom)
|
||||
expected.atom_style = "atomic";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.map_style = 1;
|
||||
expected.map_user = 1;
|
||||
expected.map_style = Atom::MAP_ARRAY;
|
||||
expected.map_user = Atom::MAP_ARRAY;
|
||||
expected.has_type = true;
|
||||
expected.has_image = true;
|
||||
expected.has_mask = true;
|
||||
@ -4663,7 +4664,7 @@ TEST_F(AtomStyleTest, property_atom)
|
||||
ASSERT_NE(lmp->atom->sametag, nullptr);
|
||||
ASSERT_EQ(lmp->atom->tag_consecutive(), 1);
|
||||
ASSERT_EQ(lmp->atom->map_style, Atom::MAP_ARRAY);
|
||||
ASSERT_EQ(lmp->atom->map_user, 1);
|
||||
ASSERT_EQ(lmp->atom->map_user, Atom::MAP_ARRAY);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 4);
|
||||
|
||||
auto x = lmp->atom->x;
|
||||
@ -4751,6 +4752,7 @@ TEST_F(AtomStyleTest, property_atom)
|
||||
expected.has_ianame = true;
|
||||
expected.has_daname = true;
|
||||
expected.nextra_store = 12;
|
||||
expected.map_user = Atom::MAP_NONE;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
ASSERT_NE(lmp->atom->avec, nullptr);
|
||||
|
||||
@ -324,7 +324,6 @@ TEST_F(FileOperationsTest, write_restart)
|
||||
command("write_restart multi-%.restart");
|
||||
command("write_restart multi2-%.restart fileper 2");
|
||||
command("write_restart multi3-%.restart nfile 1");
|
||||
if (Info::has_package("MPIIO")) command("write_restart test.restart.mpiio");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_FILE_EXISTS("noinit.restart");
|
||||
@ -336,18 +335,6 @@ TEST_F(FileOperationsTest, write_restart)
|
||||
ASSERT_FILE_EXISTS("multi2-0.restart");
|
||||
ASSERT_FILE_EXISTS("multi3-base.restart");
|
||||
ASSERT_FILE_EXISTS("multi3-0.restart");
|
||||
if (Info::has_package("MPIIO")) {
|
||||
ASSERT_FILE_EXISTS("test.restart.mpiio");
|
||||
}
|
||||
|
||||
if (!Info::has_package("MPIIO")) {
|
||||
TEST_FAILURE(".*ERROR: Writing to MPI-IO filename when MPIIO package is not inst.*",
|
||||
command("write_restart test.restart.mpiio"););
|
||||
} else {
|
||||
TEST_FAILURE(".*ERROR: Restart file MPI-IO output not allowed with % in filename.*",
|
||||
command("write_restart test.restart-%.mpiio"););
|
||||
}
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal write_restart command.*", command("write_restart"););
|
||||
TEST_FAILURE(".*ERROR: Unknown write_restart keyword: xxxx.*",
|
||||
command("write_restart test.restart xxxx"););
|
||||
@ -401,7 +388,6 @@ TEST_F(FileOperationsTest, write_restart)
|
||||
delete_file("multi3-base.restart");
|
||||
delete_file("multi3-0.restart");
|
||||
delete_file("triclinic.restart");
|
||||
if (Info::has_package("MPIIO")) delete_file("test.restart.mpiio");
|
||||
}
|
||||
|
||||
TEST_F(FileOperationsTest, write_data)
|
||||
@ -611,6 +597,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)
|
||||
|
||||
@ -117,6 +117,17 @@ TEST_F(InputConvertTest, numeric)
|
||||
TEST_FAILURE(".*ERROR: Expected floating point.*", utils::numeric(FLERR, nullptr, false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating point.*",
|
||||
utils::numeric(FLERR, "2.56D+3", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Floating point number.*out of range.*",
|
||||
utils::numeric(FLERR, "1.0e2000", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating .*", utils::numeric(FLERR, "--546700-", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating.*", utils::numeric(FLERR, "546700+", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating.*", utils::numeric(FLERR, "--546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating.*", utils::numeric(FLERR, "++546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating.*", utils::numeric(FLERR, "+-546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating .*", utils::numeric(FLERR, "5.467e--1", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating.*", utils::numeric(FLERR, "4.4e++1", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating.*", utils::numeric(FLERR, "--5.0460", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected floating.*", utils::numeric(FLERR, "++5.4670", false, lmp););
|
||||
}
|
||||
|
||||
TEST_F(InputConvertTest, inumeric)
|
||||
@ -142,6 +153,13 @@ TEST_F(InputConvertTest, inumeric)
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "0x05", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, nullptr, false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Integer.*out of range.*",
|
||||
utils::inumeric(FLERR, "1263012546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "--546700-", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "546700+", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "--546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "++546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "+-546700", false, lmp););
|
||||
}
|
||||
|
||||
TEST_F(InputConvertTest, bnumeric)
|
||||
@ -167,6 +185,13 @@ TEST_F(InputConvertTest, bnumeric)
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "0x05", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, nullptr, false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Integer.*out of range.*",
|
||||
utils::bnumeric(FLERR, "18446744073709551616123", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "--546700-", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "546700+", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "--546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "++546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "+-546700", false, lmp););
|
||||
}
|
||||
|
||||
TEST_F(InputConvertTest, tnumeric)
|
||||
@ -192,6 +217,17 @@ TEST_F(InputConvertTest, tnumeric)
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "0x05", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, nullptr, false, lmp););
|
||||
#if defined(LAMMPS_SMALLBIG)
|
||||
TEST_FAILURE(".*ERROR: Integer.*out of range.*",
|
||||
utils::tnumeric(FLERR, "4294967296", false, lmp););
|
||||
#endif
|
||||
TEST_FAILURE(".*ERROR: Integer.*out of range.*",
|
||||
utils::tnumeric(FLERR, "18446744073709551616123", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "--546700-", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "546700+", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "--546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "++546700", false, lmp););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "+-546700", false, lmp););
|
||||
}
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -71,10 +71,10 @@ protected:
|
||||
// clang-format off
|
||||
const char *args[] =
|
||||
{ "LAMMPS_Fortran_test", "-l", "none", "-echo", "screen", "-nocite",
|
||||
"-var", "input_dir", input_dir, "-var", "zpos", "1.5", "-var", "x", "2" };
|
||||
"-var", "input_dir", input_dir, "-var", "zpos", "1.5", "-var", "x", "2", nullptr };
|
||||
// clang-format on
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(const char *);
|
||||
int argc = (sizeof(args) / sizeof(const char *)) - 1;
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = (LAMMPS_NS::LAMMPS *)f_lammps_with_c_args(argc, argv);
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -106,31 +106,21 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string testbinary = "LAMMPSTest";
|
||||
std::vector<std::string> args = {"-log", "none", "-echo", "screen", "-nocite"};
|
||||
std::string testbinary = "LAMMPSTest";
|
||||
LAMMPS::argv args = {"-log", "none", "-echo", "screen", "-nocite"};
|
||||
LAMMPS *lmp;
|
||||
Info *info;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
int argc = args.size() + 1;
|
||||
char **argv = new char *[argc];
|
||||
argv[0] = LAMMPS_NS::utils::strdup(testbinary);
|
||||
for (int i = 1; i < argc; i++) {
|
||||
argv[i] = LAMMPS_NS::utils::strdup(args[i - 1]);
|
||||
}
|
||||
LAMMPS::argv full_args = {testbinary};
|
||||
full_args.insert(full_args.end(), args.begin(), args.end());
|
||||
|
||||
HIDE_OUTPUT([&] {
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(full_args, MPI_COMM_WORLD);
|
||||
info = new Info(lmp);
|
||||
});
|
||||
InitSystem();
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
delete[] argv[i];
|
||||
argv[i] = nullptr;
|
||||
}
|
||||
delete[] argv;
|
||||
}
|
||||
|
||||
virtual void InitSystem() {}
|
||||
|
||||
@ -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>)
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user