Merge pull request #2704 from rbberger/compress_package
More refactoring of COMPRESS package
This commit is contained in:
@ -102,6 +102,11 @@ target_link_libraries(test_dump_cfg PRIVATE lammps GTest::GMock GTest::GTest)
|
||||
add_test(NAME DumpCfg COMMAND test_dump_cfg WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set_tests_properties(DumpCfg PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
||||
|
||||
add_executable(test_dump_local test_dump_local.cpp)
|
||||
target_link_libraries(test_dump_local PRIVATE lammps GTest::GMock GTest::GTest)
|
||||
add_test(NAME DumpLocal COMMAND test_dump_local WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set_tests_properties(DumpLocal PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
||||
|
||||
if(BUILD_TOOLS)
|
||||
set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "BINARY2TXT_BINARY=$<TARGET_FILE:binary2txt>")
|
||||
set_tests_properties(DumpCustom PROPERTIES ENVIRONMENT "BINARY2TXT_BINARY=$<TARGET_FILE:binary2txt>")
|
||||
|
||||
@ -135,7 +135,7 @@ TEST_F(DumpAtomTest, no_scale_run0)
|
||||
TEST_F(DumpAtomTest, no_buffer_no_scale_run0)
|
||||
{
|
||||
auto dump_file = "dump_no_buffer_no_scale_run0.melt";
|
||||
generate_dump(dump_file, "scale no", 0);
|
||||
generate_dump(dump_file, "buffer no scale no", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
|
||||
@ -61,6 +61,34 @@ TEST_F(DumpAtomCompressTest, compressed_run0)
|
||||
delete_file(converted_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpAtomCompressTest, compressed_no_buffer_run0)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = text_dump_filename("no_buffer_run0.melt");
|
||||
auto compressed_file = compressed_dump_filename("no_buffer_run0.melt");
|
||||
|
||||
if(compression_style == "atom/zstd") {
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "buffer no", "buffer no checksum yes", 0);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "", "buffer no", 0);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file);
|
||||
ASSERT_FILE_EXISTS(compressed_file);
|
||||
|
||||
auto converted_file = convert_compressed_to_text(compressed_file);
|
||||
|
||||
ASSERT_THAT(converted_file, Eq(converted_dump_filename("no_buffer_run0.melt")));
|
||||
ASSERT_FILE_EXISTS(converted_file);
|
||||
ASSERT_FILE_EQUAL(text_file, converted_file);
|
||||
delete_file(text_file);
|
||||
delete_file(compressed_file);
|
||||
delete_file(converted_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpAtomCompressTest, compressed_multi_file_run1)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
@ -344,7 +372,7 @@ TEST_F(DumpAtomCompressTest, compressed_modify_bad_param)
|
||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt")));
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 compression_level 12");
|
||||
);
|
||||
}
|
||||
@ -357,7 +385,7 @@ TEST_F(DumpAtomCompressTest, compressed_modify_multi_bad_param)
|
||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt")));
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 pad 3 compression_level 12");
|
||||
);
|
||||
}
|
||||
|
||||
@ -66,6 +66,39 @@ TEST_F(DumpCfgCompressTest, compressed_run0)
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpCfgCompressTest, compressed_no_buffer_run0)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
|
||||
auto base_name = "no_buffer_run*.melt.cfg";
|
||||
auto text_files = text_dump_filename(base_name);
|
||||
auto compressed_files = compressed_dump_filename(base_name);
|
||||
|
||||
auto base_name_0 = "no_buffer_run0.melt.cfg";
|
||||
auto text_file_0 = text_dump_filename(base_name_0);
|
||||
auto compressed_file_0 = compressed_dump_filename(base_name_0);
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
if(compression_style == "cfg/zstd") {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "buffer no", "buffer no", 0);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, "buffer no", 0);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file_0);
|
||||
ASSERT_FILE_EXISTS(compressed_file_0);
|
||||
|
||||
auto converted_file_0 = convert_compressed_to_text(compressed_file_0);
|
||||
|
||||
ASSERT_FILE_EXISTS(converted_file_0);
|
||||
ASSERT_FILE_EQUAL(text_file_0, converted_file_0);
|
||||
delete_file(text_file_0);
|
||||
delete_file(compressed_file_0);
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpCfgCompressTest, compressed_unwrap_run0)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
@ -234,7 +267,7 @@ TEST_F(DumpCfgCompressTest, compressed_modify_bad_param)
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.cfg"), fields));
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 compression_level 12");
|
||||
);
|
||||
}
|
||||
@ -248,7 +281,7 @@ TEST_F(DumpCfgCompressTest, compressed_modify_multi_bad_param)
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.cfg"), fields));
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 pad 3 compression_level 12");
|
||||
);
|
||||
}
|
||||
|
||||
@ -58,6 +58,64 @@ TEST_F(DumpCustomCompressTest, compressed_run1)
|
||||
delete_file(converted_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpCustomCompressTest, compressed_with_time_run1)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
|
||||
auto base_name = "with_time_custom_run1.melt";
|
||||
auto text_file = text_dump_filename(base_name);
|
||||
auto compressed_file = compressed_dump_filename(base_name);
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
if(compression_style == "custom/zstd") {
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "time yes", "time yes checksum yes", 1);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, fields, "time yes", 1);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file);
|
||||
ASSERT_FILE_EXISTS(compressed_file);
|
||||
|
||||
auto converted_file = convert_compressed_to_text(compressed_file);
|
||||
|
||||
ASSERT_FILE_EXISTS(converted_file);
|
||||
ASSERT_FILE_EQUAL(text_file, converted_file);
|
||||
delete_file(text_file);
|
||||
delete_file(compressed_file);
|
||||
delete_file(converted_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpCustomCompressTest, compressed_no_buffer_run1)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
|
||||
auto base_name = "no_buffer_custom_run1.melt";
|
||||
auto text_file = text_dump_filename(base_name);
|
||||
auto compressed_file = compressed_dump_filename(base_name);
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
if(compression_style == "custom/zstd") {
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "buffer no", "buffer no checksum yes", 1);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, fields, "buffer no", 1);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file);
|
||||
ASSERT_FILE_EXISTS(compressed_file);
|
||||
|
||||
auto converted_file = convert_compressed_to_text(compressed_file);
|
||||
|
||||
ASSERT_FILE_EXISTS(converted_file);
|
||||
ASSERT_FILE_EQUAL(text_file, converted_file);
|
||||
delete_file(text_file);
|
||||
delete_file(compressed_file);
|
||||
delete_file(converted_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpCustomCompressTest, compressed_triclinic_run1)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
@ -222,7 +280,7 @@ TEST_F(DumpCustomCompressTest, compressed_modify_bad_param)
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.custom"), fields));
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 compression_level 12");
|
||||
);
|
||||
}
|
||||
@ -234,7 +292,7 @@ TEST_F(DumpCustomCompressTest, compressed_modify_multi_bad_param)
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.custom"), fields));
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 pad 3 compression_level 12");
|
||||
);
|
||||
}
|
||||
|
||||
261
unittest/formats/test_dump_local.cpp
Normal file
261
unittest/formats/test_dump_local.cpp
Normal file
@ -0,0 +1,261 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://lammps.sandia.gov/, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "output.h"
|
||||
#include "thermo.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
char *BINARY2TXT_BINARY = nullptr;
|
||||
bool verbose = false;
|
||||
|
||||
class DumpLocalTest : public MeltTest {
|
||||
std::string dump_style = "local";
|
||||
|
||||
public:
|
||||
void enable_triclinic()
|
||||
{
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("change_box all triclinic");
|
||||
END_HIDE_OUTPUT();
|
||||
}
|
||||
|
||||
void generate_dump(std::string dump_file, std::string dump_options, std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, dump_options));
|
||||
|
||||
if (!dump_modify_options.empty()) {
|
||||
command(fmt::format("dump_modify id {}", dump_modify_options));
|
||||
}
|
||||
|
||||
command(fmt::format("run {} post no", ntimesteps));
|
||||
END_HIDE_OUTPUT();
|
||||
}
|
||||
|
||||
void continue_dump(int ntimesteps)
|
||||
{
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command(fmt::format("run {} pre no post no", ntimesteps));
|
||||
END_HIDE_OUTPUT();
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
MeltTest::SetUp();
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("compute comp all pair/local dist eng");
|
||||
END_HIDE_OUTPUT();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(DumpLocalTest, run0)
|
||||
{
|
||||
auto dump_file = "dump_local_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
ASSERT_EQ(lines.size(), 873);
|
||||
|
||||
ASSERT_THAT(lines[0], Eq("ITEM: TIMESTEP"));
|
||||
ASSERT_EQ(std::stoi(lines[1]), 0);
|
||||
|
||||
ASSERT_THAT(lines[2], Eq("ITEM: NUMBER OF ENTRIES"));
|
||||
ASSERT_EQ(std::stoi(lines[3]), 864);
|
||||
|
||||
ASSERT_THAT(lines[4], Eq("ITEM: BOX BOUNDS pp pp pp"));
|
||||
ASSERT_EQ(utils::split_words(lines[5]).size(), 2);
|
||||
ASSERT_EQ(utils::split_words(lines[6]).size(), 2);
|
||||
ASSERT_EQ(utils::split_words(lines[7]).size(), 2);
|
||||
ASSERT_THAT(lines[8], Eq("ITEM: ENTRIES index c_comp[1] "));
|
||||
ASSERT_EQ(utils::split_words(lines[9]).size(), 2);
|
||||
ASSERT_THAT(lines[9], Eq("1 1.18765 "));
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, label_run0)
|
||||
{
|
||||
auto dump_file = "dump_local_label_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "label ELEMENTS", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
ASSERT_THAT(lines[2], Eq("ITEM: NUMBER OF ELEMENTS"));
|
||||
ASSERT_THAT(lines[8], Eq("ITEM: ELEMENTS index c_comp[1] "));
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, format_line_run0)
|
||||
{
|
||||
auto dump_file = "dump_local_format_line_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "format line \"%d %20.8g\"", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
|
||||
ASSERT_EQ(utils::split_words(lines[9]).size(), 2);
|
||||
ASSERT_THAT(lines[9], Eq("1 1.1876539 "));
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, format_int_run0)
|
||||
{
|
||||
auto dump_file = "dump_local_format_int_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "format int \"%20d\"", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
|
||||
ASSERT_EQ(utils::split_words(lines[9]).size(), 2);
|
||||
ASSERT_THAT(lines[9], Eq(" 1 1.18765 "));
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, format_float_run0)
|
||||
{
|
||||
auto dump_file = "dump_local_format_float_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "format float \"%20.5g\"", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
|
||||
ASSERT_EQ(utils::split_words(lines[9]).size(), 2);
|
||||
ASSERT_THAT(lines[9], Eq("1 1.1877 "));
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, format_column_run0)
|
||||
{
|
||||
auto dump_file = "dump_local_format_column_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "format 1 \"%20d\"", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
|
||||
ASSERT_EQ(utils::split_words(lines[9]).size(), 2);
|
||||
ASSERT_THAT(lines[9], Eq(" 1 1.18765 "));
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, no_buffer_run0)
|
||||
{
|
||||
auto dump_file = "dump_local_format_line_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "buffer no", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
ASSERT_EQ(lines.size(), 873);
|
||||
|
||||
ASSERT_THAT(lines[0], Eq("ITEM: TIMESTEP"));
|
||||
ASSERT_EQ(std::stoi(lines[1]), 0);
|
||||
|
||||
ASSERT_THAT(lines[2], Eq("ITEM: NUMBER OF ENTRIES"));
|
||||
ASSERT_EQ(std::stoi(lines[3]), 864);
|
||||
|
||||
ASSERT_THAT(lines[4], Eq("ITEM: BOX BOUNDS pp pp pp"));
|
||||
ASSERT_EQ(utils::split_words(lines[5]).size(), 2);
|
||||
ASSERT_EQ(utils::split_words(lines[6]).size(), 2);
|
||||
ASSERT_EQ(utils::split_words(lines[7]).size(), 2);
|
||||
ASSERT_THAT(lines[8], Eq("ITEM: ENTRIES index c_comp[1] "));
|
||||
ASSERT_EQ(utils::split_words(lines[9]).size(), 2);
|
||||
ASSERT_THAT(lines[9], Eq("1 1.18765 "));
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, with_units_run0)
|
||||
{
|
||||
auto dump_file = "dump_with_units_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "units yes", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
ASSERT_EQ(lines.size(), 875);
|
||||
|
||||
ASSERT_THAT(lines[0], Eq("ITEM: UNITS"));
|
||||
ASSERT_THAT(lines[1], Eq("lj"));
|
||||
|
||||
ASSERT_THAT(lines[2], Eq("ITEM: TIMESTEP"));
|
||||
ASSERT_EQ(std::stoi(lines[3]), 0);
|
||||
|
||||
ASSERT_THAT(lines[4], Eq("ITEM: NUMBER OF ENTRIES"));
|
||||
ASSERT_EQ(std::stoi(lines[5]), 864);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, with_time_run0)
|
||||
{
|
||||
auto dump_file = "dump_with_time_run0.melt";
|
||||
generate_dump(dump_file, "index c_comp[1]", "time yes", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
ASSERT_EQ(lines.size(), 875);
|
||||
|
||||
ASSERT_THAT(lines[0], Eq("ITEM: TIME"));
|
||||
ASSERT_THAT(std::stof(lines[1]), 0.0);
|
||||
|
||||
ASSERT_THAT(lines[2], Eq("ITEM: TIMESTEP"));
|
||||
ASSERT_EQ(std::stoi(lines[3]), 0);
|
||||
|
||||
ASSERT_THAT(lines[4], Eq("ITEM: NUMBER OF ENTRIES"));
|
||||
ASSERT_EQ(std::stoi(lines[5]), 864);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalTest, triclinic_run0)
|
||||
{
|
||||
auto dump_file = "dump_local_triclinic_run0.melt";
|
||||
enable_triclinic();
|
||||
generate_dump(dump_file, "index c_comp[1]", "", 0);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
auto lines = read_lines(dump_file);
|
||||
|
||||
ASSERT_THAT(lines[4], Eq("ITEM: BOX BOUNDS xy xz yz pp pp pp"));
|
||||
ASSERT_EQ(utils::split_words(lines[5]).size(), 3);
|
||||
ASSERT_EQ(utils::split_words(lines[6]).size(), 3);
|
||||
ASSERT_EQ(utils::split_words(lines[7]).size(), 3);
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MPI_Init(&argc, &argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
|
||||
// handle arguments passed via environment variable
|
||||
if (const char *var = getenv("TEST_ARGS")) {
|
||||
std::vector<std::string> env = utils::split_words(var);
|
||||
for (auto arg : env) {
|
||||
if (arg == "-v") {
|
||||
verbose = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BINARY2TXT_BINARY = getenv("BINARY2TXT_BINARY");
|
||||
|
||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
||||
|
||||
int rv = RUN_ALL_TESTS();
|
||||
MPI_Finalize();
|
||||
return rv;
|
||||
}
|
||||
@ -69,6 +69,135 @@ TEST_F(DumpLocalCompressTest, compressed_run0)
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalCompressTest, compressed_no_buffer_run0)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
|
||||
auto base_name = "no_buffer_run*.melt.local";
|
||||
auto base_name_0 = "no_buffer_run0.melt.local";
|
||||
auto text_files = text_dump_filename(base_name);
|
||||
auto compressed_files = compressed_dump_filename(base_name);
|
||||
auto text_file_0 = text_dump_filename(base_name_0);
|
||||
auto compressed_file_0 = compressed_dump_filename(base_name_0);
|
||||
auto fields = "index c_comp[1]";
|
||||
|
||||
if(compression_style == "local/zstd") {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "buffer no", "buffer no checksum yes", 0);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, "buffer no", 0);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file_0);
|
||||
ASSERT_FILE_EXISTS(compressed_file_0);
|
||||
|
||||
auto converted_file_0 = convert_compressed_to_text(compressed_file_0);
|
||||
|
||||
ASSERT_FILE_EXISTS(converted_file_0);
|
||||
ASSERT_FILE_EQUAL(text_file_0, converted_file_0);
|
||||
delete_file(text_file_0);
|
||||
delete_file(compressed_file_0);
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalCompressTest, compressed_with_time_run0)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
|
||||
auto base_name = "with_time_run*.melt.local";
|
||||
auto base_name_0 = "with_time_run0.melt.local";
|
||||
auto text_files = text_dump_filename(base_name);
|
||||
auto compressed_files = compressed_dump_filename(base_name);
|
||||
auto text_file_0 = text_dump_filename(base_name_0);
|
||||
auto compressed_file_0 = compressed_dump_filename(base_name_0);
|
||||
auto fields = "index c_comp[1]";
|
||||
|
||||
if(compression_style == "local/zstd") {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "time yes", "time yes checksum yes", 0);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, "time yes", 0);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file_0);
|
||||
ASSERT_FILE_EXISTS(compressed_file_0);
|
||||
|
||||
auto converted_file_0 = convert_compressed_to_text(compressed_file_0);
|
||||
|
||||
ASSERT_FILE_EXISTS(converted_file_0);
|
||||
ASSERT_FILE_EQUAL(text_file_0, converted_file_0);
|
||||
delete_file(text_file_0);
|
||||
delete_file(compressed_file_0);
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalCompressTest, compressed_with_units_run0)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
|
||||
auto base_name = "with_units_run*.melt.local";
|
||||
auto base_name_0 = "with_units_run0.melt.local";
|
||||
auto text_files = text_dump_filename(base_name);
|
||||
auto compressed_files = compressed_dump_filename(base_name);
|
||||
auto text_file_0 = text_dump_filename(base_name_0);
|
||||
auto compressed_file_0 = compressed_dump_filename(base_name_0);
|
||||
auto fields = "index c_comp[1]";
|
||||
|
||||
if(compression_style == "local/zstd") {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "units yes", "units yes checksum yes", 0);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, "units yes", 0);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file_0);
|
||||
ASSERT_FILE_EXISTS(compressed_file_0);
|
||||
|
||||
auto converted_file_0 = convert_compressed_to_text(compressed_file_0);
|
||||
|
||||
ASSERT_FILE_EXISTS(converted_file_0);
|
||||
ASSERT_FILE_EQUAL(text_file_0, converted_file_0);
|
||||
delete_file(text_file_0);
|
||||
delete_file(compressed_file_0);
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalCompressTest, compressed_triclinic_run0)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
enable_triclinic();
|
||||
|
||||
auto base_name = "triclinic_run*.melt.local";
|
||||
auto base_name_0 = "triclinic_run0.melt.local";
|
||||
auto text_files = text_dump_filename(base_name);
|
||||
auto compressed_files = compressed_dump_filename(base_name);
|
||||
auto text_file_0 = text_dump_filename(base_name_0);
|
||||
auto compressed_file_0 = compressed_dump_filename(base_name_0);
|
||||
auto fields = "index c_comp[1]";
|
||||
|
||||
if(compression_style == "local/zstd") {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "", "checksum yes", 0);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, fields, "", 0);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file_0);
|
||||
ASSERT_FILE_EXISTS(compressed_file_0);
|
||||
|
||||
auto converted_file_0 = convert_compressed_to_text(compressed_file_0);
|
||||
|
||||
ASSERT_FILE_EXISTS(converted_file_0);
|
||||
ASSERT_FILE_EQUAL(text_file_0, converted_file_0);
|
||||
delete_file(text_file_0);
|
||||
delete_file(compressed_file_0);
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpLocalCompressTest, compressed_multi_file_run1)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
@ -209,7 +338,7 @@ TEST_F(DumpLocalCompressTest, compressed_modify_bad_param)
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.local"), fields));
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 compression_level 12");
|
||||
);
|
||||
}
|
||||
@ -224,7 +353,7 @@ TEST_F(DumpLocalCompressTest, compressed_modify_multi_bad_param)
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.local"), fields));
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 pad 3 compression_level 12");
|
||||
);
|
||||
}
|
||||
|
||||
@ -60,6 +60,37 @@ TEST_F(DumpXYZCompressTest, compressed_run0)
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpXYZCompressTest, compressed_no_buffer_run0)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
|
||||
auto base_name = "no_buffer_run*.melt.xyz";
|
||||
auto base_name_0 = "no_buffer_run0.melt.xyz";
|
||||
auto text_files = text_dump_filename(base_name);
|
||||
auto compressed_files = compressed_dump_filename(base_name);
|
||||
auto text_file_0 = text_dump_filename(base_name_0);
|
||||
auto compressed_file_0 = compressed_dump_filename(base_name_0);
|
||||
|
||||
if(compression_style == "xyz/zstd") {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "", "", "buffer no", "buffer no", 0);
|
||||
} else {
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "", "buffer no", 0);
|
||||
}
|
||||
|
||||
TearDown();
|
||||
|
||||
ASSERT_FILE_EXISTS(text_file_0);
|
||||
ASSERT_FILE_EXISTS(compressed_file_0);
|
||||
|
||||
auto converted_file_0 = convert_compressed_to_text(compressed_file_0);
|
||||
|
||||
ASSERT_FILE_EXISTS(converted_file_0);
|
||||
ASSERT_FILE_EQUAL(text_file_0, converted_file_0);
|
||||
delete_file(text_file_0);
|
||||
delete_file(compressed_file_0);
|
||||
delete_file(converted_file_0);
|
||||
}
|
||||
|
||||
TEST_F(DumpXYZCompressTest, compressed_multi_file_run1)
|
||||
{
|
||||
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||
@ -195,7 +226,7 @@ TEST_F(DumpXYZCompressTest, compressed_modify_bad_param)
|
||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.xyz")));
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 compression_level 12");
|
||||
);
|
||||
}
|
||||
@ -208,7 +239,7 @@ TEST_F(DumpXYZCompressTest, compressed_modify_multi_bad_param)
|
||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.xyz")));
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
|
||||
command("dump_modify id1 pad 3 compression_level 12");
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user