Add more compression tests for dump custom

This commit is contained in:
Richard Berger
2021-03-11 13:12:43 -05:00
parent 7e3d1923ab
commit f53fcf0545
4 changed files with 188 additions and 0 deletions

View File

@ -332,7 +332,9 @@ TEST_F(DumpAtomCompressTest, compressed_modify_bad_param)
{ {
if (compression_style != "atom/gz") GTEST_SKIP(); if (compression_style != "atom/gz") GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt"))); command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt")));
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*", TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 compression_level 12"); command("dump_modify id1 compression_level 12");
@ -343,7 +345,9 @@ TEST_F(DumpAtomCompressTest, compressed_modify_multi_bad_param)
{ {
if (compression_style != "atom/gz") GTEST_SKIP(); if (compression_style != "atom/gz") GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt"))); command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt")));
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*", TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12"); command("dump_modify id1 pad 3 compression_level 12");

View File

@ -222,7 +222,9 @@ TEST_F(DumpCfgCompressTest, compressed_modify_bad_param)
if (compression_style != "cfg/gz") GTEST_SKIP(); if (compression_style != "cfg/gz") GTEST_SKIP();
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz"; auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.cfg"), fields)); command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.cfg"), fields));
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*", TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 compression_level 12"); command("dump_modify id1 compression_level 12");
@ -234,7 +236,9 @@ TEST_F(DumpCfgCompressTest, compressed_modify_multi_bad_param)
if (compression_style != "cfg/gz") GTEST_SKIP(); if (compression_style != "cfg/gz") GTEST_SKIP();
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz"; auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.cfg"), fields)); command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.cfg"), fields));
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*", TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12"); command("dump_modify id1 pad 3 compression_level 12");

View File

@ -81,6 +81,182 @@ TEST_F(DumpCustomCompressTest, compressed_triclinic_run1)
delete_file(converted_file); delete_file(converted_file);
} }
TEST_F(DumpCustomCompressTest, compressed_multi_file_run1)
{
if (!COMPRESS_BINARY) GTEST_SKIP();
auto base_name = "multi_file_run1_*.melt.custom";
auto base_name_0 = "multi_file_run1_0.melt.custom";
auto base_name_1 = "multi_file_run1_1.melt.custom";
auto text_file = text_dump_filename(base_name);
auto text_file_0 = text_dump_filename(base_name_0);
auto text_file_1 = text_dump_filename(base_name_1);
auto compressed_file = compressed_dump_filename(base_name);
auto compressed_file_0 = compressed_dump_filename(base_name_0);
auto compressed_file_1 = compressed_dump_filename(base_name_1);
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";
generate_text_and_compressed_dump(text_file, compressed_file, fields, "", 1);
TearDown();
auto converted_file_0 = convert_compressed_to_text(compressed_file_0);
auto converted_file_1 = convert_compressed_to_text(compressed_file_1);
ASSERT_THAT(converted_file_0, Eq(converted_dump_filename(base_name_0)));
ASSERT_THAT(converted_file_1, Eq(converted_dump_filename(base_name_1)));
ASSERT_FILE_EXISTS(converted_file_0);
ASSERT_FILE_EXISTS(converted_file_1);
ASSERT_FILE_EQUAL(text_file_0, converted_file_0);
ASSERT_FILE_EQUAL(text_file_1, converted_file_1);
delete_file(text_file_0);
delete_file(text_file_1);
delete_file(compressed_file_0);
delete_file(compressed_file_1);
delete_file(converted_file_0);
delete_file(converted_file_1);
}
TEST_F(DumpCustomCompressTest, compressed_multi_file_with_pad_run1)
{
if (!COMPRESS_BINARY) GTEST_SKIP();
auto base_name = "multi_file_pad_run1_*.melt.custom";
auto base_name_0 = "multi_file_pad_run1_000.melt.custom";
auto base_name_1 = "multi_file_pad_run1_001.melt.custom";
auto text_file = text_dump_filename(base_name);
auto text_file_0 = text_dump_filename(base_name_0);
auto text_file_1 = text_dump_filename(base_name_1);
auto compressed_file = compressed_dump_filename(base_name);
auto compressed_file_0 = compressed_dump_filename(base_name_0);
auto compressed_file_1 = compressed_dump_filename(base_name_1);
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";
generate_text_and_compressed_dump(text_file, compressed_file, fields, "pad 3", 1);
TearDown();
ASSERT_FILE_EXISTS(text_file_0);
ASSERT_FILE_EXISTS(text_file_1);
ASSERT_FILE_EXISTS(compressed_file_0);
ASSERT_FILE_EXISTS(compressed_file_1);
auto converted_file_0 = convert_compressed_to_text(compressed_file_0);
auto converted_file_1 = convert_compressed_to_text(compressed_file_1);
ASSERT_THAT(converted_file_0, Eq(converted_dump_filename(base_name_0)));
ASSERT_THAT(converted_file_1, Eq(converted_dump_filename(base_name_1)));
ASSERT_FILE_EXISTS(converted_file_0);
ASSERT_FILE_EXISTS(converted_file_1);
ASSERT_FILE_EQUAL(text_file_0, converted_file_0);
ASSERT_FILE_EQUAL(text_file_1, converted_file_1);
delete_file(text_file_0);
delete_file(text_file_1);
delete_file(compressed_file_0);
delete_file(compressed_file_1);
delete_file(converted_file_0);
delete_file(converted_file_1);
}
TEST_F(DumpCustomCompressTest, compressed_multi_file_with_maxfiles_run1)
{
if (!COMPRESS_BINARY) GTEST_SKIP();
auto base_name = "multi_file_maxfiles_run1_*.melt.custom";
auto base_name_0 = "multi_file_maxfiles_run1_0.melt.custom";
auto base_name_1 = "multi_file_maxfiles_run1_1.melt.custom";
auto base_name_2 = "multi_file_maxfiles_run1_2.melt.custom";
auto text_file = text_dump_filename(base_name);
auto text_file_0 = text_dump_filename(base_name_0);
auto text_file_1 = text_dump_filename(base_name_1);
auto text_file_2 = text_dump_filename(base_name_2);
auto compressed_file = compressed_dump_filename(base_name);
auto compressed_file_0 = compressed_dump_filename(base_name_0);
auto compressed_file_1 = compressed_dump_filename(base_name_1);
auto compressed_file_2 = compressed_dump_filename(base_name_2);
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";
generate_text_and_compressed_dump(text_file, compressed_file, fields, "maxfiles 2", 2);
TearDown();
ASSERT_FILE_NOT_EXISTS(text_file_0);
ASSERT_FILE_EXISTS(text_file_1);
ASSERT_FILE_EXISTS(text_file_2);
ASSERT_FILE_NOT_EXISTS(compressed_file_0);
ASSERT_FILE_EXISTS(compressed_file_1);
ASSERT_FILE_EXISTS(compressed_file_2);
auto converted_file_1 = convert_compressed_to_text(compressed_file_1);
auto converted_file_2 = convert_compressed_to_text(compressed_file_2);
ASSERT_THAT(converted_file_1, Eq(converted_dump_filename(base_name_1)));
ASSERT_THAT(converted_file_2, Eq(converted_dump_filename(base_name_2)));
ASSERT_FILE_EXISTS(converted_file_1);
ASSERT_FILE_EXISTS(converted_file_2);
ASSERT_FILE_EQUAL(text_file_1, converted_file_1);
ASSERT_FILE_EQUAL(text_file_2, converted_file_2);
delete_file(text_file_1);
delete_file(text_file_2);
delete_file(compressed_file_1);
delete_file(compressed_file_2);
delete_file(converted_file_1);
delete_file(converted_file_2);
}
TEST_F(DumpCustomCompressTest, compressed_modify_bad_param)
{
if (compression_style != "custom/gz") GTEST_SKIP();
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.*",
command("dump_modify id1 compression_level 12");
);
}
TEST_F(DumpCustomCompressTest, compressed_modify_multi_bad_param)
{
if (compression_style != "custom/gz") GTEST_SKIP();
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.*",
command("dump_modify id1 pad 3 compression_level 12");
);
}
TEST_F(DumpCustomCompressTest, compressed_modify_clevel_run0)
{
if (!COMPRESS_BINARY) GTEST_SKIP();
auto base_name = "modify_clevel_run0.melt.custom";
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";
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "compression_level 3", 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(base_name)));
ASSERT_FILE_EXISTS(converted_file);
ASSERT_FILE_EQUAL(text_file, converted_file);
delete_file(text_file);
delete_file(compressed_file);
delete_file(converted_file);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);

View File

@ -183,7 +183,9 @@ TEST_F(DumpXYZCompressTest, compressed_modify_bad_param)
{ {
if (compression_style != "xyz/gz") GTEST_SKIP(); if (compression_style != "xyz/gz") GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.xyz"))); command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.xyz")));
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*", TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 compression_level 12"); command("dump_modify id1 compression_level 12");
@ -194,7 +196,9 @@ TEST_F(DumpXYZCompressTest, compressed_modify_multi_bad_param)
{ {
if (compression_style != "xyz/gz") GTEST_SKIP(); if (compression_style != "xyz/gz") GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.xyz"))); command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.xyz")));
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*", TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12"); command("dump_modify id1 pad 3 compression_level 12");