Correctly build argv with nullptr at the end

This commit is contained in:
Richard Berger
2023-11-06 23:18:42 -07:00
committed by Richard Berger
parent e655cda066
commit 46768d0ff3
22 changed files with 207 additions and 283 deletions

View File

@ -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();