add some basic tests for the "processors" command

This commit is contained in:
Axel Kohlmeyer 2021-04-25 00:44:51 -04:00
parent 43325dca82
commit ba5f531619
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 34 additions and 0 deletions

View File

@ -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 <cstdio>
#include <cstring>
@ -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();