From ba5f531619d0eba24ec82298c382085b0d5f7c8d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 25 Apr 2021 00:44:51 -0400 Subject: [PATCH] add some basic tests for the "processors" command --- unittest/commands/test_simple_commands.cpp | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp index e8cebe98e2..ac8317b3da 100644 --- a/unittest/commands/test_simple_commands.cpp +++ b/unittest/commands/test_simple_commands.cpp @@ -14,6 +14,7 @@ #include "lammps.h" #include "citeme.h" +#include "comm.h" #include "force.h" #include "info.h" #include "input.h" @@ -25,6 +26,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "../testing/core.h" +#include "../testing/utils.h" #include #include @@ -174,6 +176,38 @@ TEST_F(SimpleCommandsTest, Partition) ASSERT_THAT(text, StrEq("")); } +TEST_F(SimpleCommandsTest, Processors) +{ + // default setting is "*" for all dimensions + ASSERT_EQ(lmp->comm->user_procgrid[0], 0); + ASSERT_EQ(lmp->comm->user_procgrid[1], 0); + ASSERT_EQ(lmp->comm->user_procgrid[2], 0); + + BEGIN_HIDE_OUTPUT(); + command("processors 1 1 1"); + END_HIDE_OUTPUT(); + ASSERT_EQ(lmp->comm->user_procgrid[0], 1); + ASSERT_EQ(lmp->comm->user_procgrid[1], 1); + ASSERT_EQ(lmp->comm->user_procgrid[2], 1); + + BEGIN_HIDE_OUTPUT(); + command("processors * 1 *"); + END_HIDE_OUTPUT(); + ASSERT_EQ(lmp->comm->user_procgrid[0], 0); + ASSERT_EQ(lmp->comm->user_procgrid[1], 1); + ASSERT_EQ(lmp->comm->user_procgrid[2], 0); + + BEGIN_HIDE_OUTPUT(); + command("processors 0 0 0"); + END_HIDE_OUTPUT(); + ASSERT_EQ(lmp->comm->user_procgrid[0], 0); + ASSERT_EQ(lmp->comm->user_procgrid[1], 0); + ASSERT_EQ(lmp->comm->user_procgrid[2], 0); + + TEST_FAILURE(".*ERROR: Illegal processors command .*", command("processors -1 0 0");); + TEST_FAILURE(".*ERROR: Specified processors != physical processors.*", command("processors 100 100 100");); +} + TEST_F(SimpleCommandsTest, Quit) { BEGIN_HIDE_OUTPUT();