Merge remote-tracking branch 'origin/master' into python_unittests
This commit is contained in:
@ -965,7 +965,7 @@ void FixBondReact::post_integrate()
|
|||||||
// forward comm of partner, so ghosts have it
|
// forward comm of partner, so ghosts have it
|
||||||
|
|
||||||
commflag = 2;
|
commflag = 2;
|
||||||
comm->forward_comm_fix(this,2);
|
comm->forward_comm_fix(this,1);
|
||||||
|
|
||||||
// consider for reaction:
|
// consider for reaction:
|
||||||
// only if both atoms list each other as winning bond partner
|
// only if both atoms list each other as winning bond partner
|
||||||
@ -2566,6 +2566,7 @@ void FixBondReact::unlimit_bond()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// really should only communicate this per-atom property, not entire reneighboring
|
// really should only communicate this per-atom property, not entire reneighboring
|
||||||
|
MPI_Allreduce(MPI_IN_PLACE,&unlimitflag,1,MPI_INT,MPI_MAX,world);
|
||||||
if (unlimitflag) next_reneighbor = update->ntimestep;
|
if (unlimitflag) next_reneighbor = update->ntimestep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,70 +40,55 @@ set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS
|
|||||||
if(PKG_COMPRESS)
|
if(PKG_COMPRESS)
|
||||||
find_program(GZIP_BINARY NAMES gzip REQUIRED)
|
find_program(GZIP_BINARY NAMES gzip REQUIRED)
|
||||||
|
|
||||||
add_executable(test_dump_atom_gz test_dump_atom_gz.cpp)
|
add_executable(test_dump_atom_compressed test_dump_atom_compressed.cpp compressed_dump_test_main.cpp)
|
||||||
target_link_libraries(test_dump_atom_gz PRIVATE lammps GTest::GMock GTest::GTest)
|
target_link_libraries(test_dump_atom_compressed PRIVATE lammps GTest::GMock GTest::GTest)
|
||||||
add_test(NAME DumpAtomGZ COMMAND test_dump_atom_gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpAtomGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpAtomGZ PROPERTIES ENVIRONMENT "GZIP_BINARY=${GZIP_BINARY}")
|
|
||||||
|
|
||||||
add_executable(test_dump_custom_gz test_dump_custom_gz.cpp)
|
add_executable(test_dump_custom_compressed test_dump_custom_compressed.cpp compressed_dump_test_main.cpp)
|
||||||
target_link_libraries(test_dump_custom_gz PRIVATE lammps GTest::GMock GTest::GTest)
|
target_link_libraries(test_dump_custom_compressed PRIVATE lammps GTest::GMock GTest::GTest)
|
||||||
add_test(NAME DumpCustomGZ COMMAND test_dump_custom_gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpCustomGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpCustomGZ PROPERTIES ENVIRONMENT "GZIP_BINARY=${GZIP_BINARY}")
|
|
||||||
|
|
||||||
add_executable(test_dump_cfg_gz test_dump_cfg_gz.cpp)
|
add_executable(test_dump_cfg_compressed test_dump_cfg_compressed.cpp compressed_dump_test_main.cpp)
|
||||||
target_link_libraries(test_dump_cfg_gz PRIVATE lammps GTest::GMock GTest::GTest)
|
target_link_libraries(test_dump_cfg_compressed PRIVATE lammps GTest::GMock GTest::GTest)
|
||||||
add_test(NAME DumpCfgGZ COMMAND test_dump_cfg_gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpCfgGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpCfgGZ PROPERTIES ENVIRONMENT "GZIP_BINARY=${GZIP_BINARY}")
|
|
||||||
|
|
||||||
add_executable(test_dump_xyz_gz test_dump_xyz_gz.cpp)
|
add_executable(test_dump_local_compressed test_dump_local_compressed.cpp compressed_dump_test_main.cpp)
|
||||||
target_link_libraries(test_dump_xyz_gz PRIVATE lammps GTest::GMock GTest::GTest)
|
target_link_libraries(test_dump_local_compressed PRIVATE lammps GTest::GMock GTest::GTest)
|
||||||
add_test(NAME DumpXYZGZ COMMAND test_dump_xyz_gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpXYZGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpXYZGZ PROPERTIES ENVIRONMENT "GZIP_BINARY=${GZIP_BINARY}")
|
|
||||||
|
|
||||||
add_executable(test_dump_local_gz test_dump_local_gz.cpp)
|
add_executable(test_dump_xyz_compressed test_dump_xyz_compressed.cpp compressed_dump_test_main.cpp)
|
||||||
target_link_libraries(test_dump_local_gz PRIVATE lammps GTest::GMock GTest::GTest)
|
target_link_libraries(test_dump_xyz_compressed PRIVATE lammps GTest::GMock GTest::GTest)
|
||||||
add_test(NAME DumpLocalGZ COMMAND test_dump_local_gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpLocalGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
add_test(NAME DumpAtomGZ COMMAND test_dump_atom_compressed gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
set_tests_properties(DumpLocalGZ PROPERTIES ENVIRONMENT "GZIP_BINARY=${GZIP_BINARY}")
|
set_tests_properties(DumpAtomGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
|
||||||
|
|
||||||
|
add_test(NAME DumpCustomGZ COMMAND test_dump_custom_compressed gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
set_tests_properties(DumpCustomGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
|
||||||
|
|
||||||
|
add_test(NAME DumpCfgGZ COMMAND test_dump_cfg_compressed gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
set_tests_properties(DumpCfgGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
|
||||||
|
|
||||||
|
add_test(NAME DumpLocalGZ COMMAND test_dump_local_compressed gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
set_tests_properties(DumpLocalGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
|
||||||
|
|
||||||
|
add_test(NAME DumpXYZGZ COMMAND test_dump_xyz_compressed gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
set_tests_properties(DumpXYZGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(Zstd IMPORTED_TARGET libzstd>=1.4)
|
pkg_check_modules(Zstd IMPORTED_TARGET libzstd>=1.4)
|
||||||
find_program(ZSTD_BINARY NAMES zstd)
|
find_program(ZSTD_BINARY NAMES zstd)
|
||||||
|
|
||||||
if(Zstd_FOUND AND ZSTD_BINARY)
|
if(Zstd_FOUND AND ZSTD_BINARY)
|
||||||
add_executable(test_dump_atom_zstd test_dump_atom_zstd.cpp)
|
add_test(NAME DumpAtomZstd COMMAND test_dump_atom_compressed zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_link_libraries(test_dump_atom_zstd PRIVATE lammps GTest::GMock GTest::GTest)
|
set_tests_properties(DumpAtomZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
|
||||||
add_test(NAME DumpAtomZstd COMMAND test_dump_atom_zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpAtomZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpAtomZstd PROPERTIES ENVIRONMENT "ZSTD_BINARY=${ZSTD_BINARY}")
|
|
||||||
|
|
||||||
add_executable(test_dump_custom_zstd test_dump_custom_zstd.cpp)
|
add_test(NAME DumpCustomZstd COMMAND test_dump_custom_compressed zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_link_libraries(test_dump_custom_zstd PRIVATE lammps GTest::GMock GTest::GTest)
|
set_tests_properties(DumpCustomZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
|
||||||
add_test(NAME DumpCustomZstd COMMAND test_dump_custom_zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpCustomZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpCustomZstd PROPERTIES ENVIRONMENT "ZSTD_BINARY=${ZSTD_BINARY}")
|
|
||||||
|
|
||||||
add_executable(test_dump_cfg_zstd test_dump_cfg_zstd.cpp)
|
add_test(NAME DumpCfgZstd COMMAND test_dump_cfg_compressed zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_link_libraries(test_dump_cfg_zstd PRIVATE lammps GTest::GMock GTest::GTest)
|
set_tests_properties(DumpCfgZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
|
||||||
add_test(NAME DumpCfgZstd COMMAND test_dump_cfg_zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpCfgZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpCfgZstd PROPERTIES ENVIRONMENT "ZSTD_BINARY=${ZSTD_BINARY}")
|
|
||||||
|
|
||||||
add_executable(test_dump_xyz_zstd test_dump_xyz_zstd.cpp)
|
add_test(NAME DumpLocalZstd COMMAND test_dump_local_compressed zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_link_libraries(test_dump_xyz_zstd PRIVATE lammps GTest::GMock GTest::GTest)
|
set_tests_properties(DumpLocalZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
|
||||||
add_test(NAME DumpXYZZstd COMMAND test_dump_xyz_zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpXYZZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpXYZZstd PROPERTIES ENVIRONMENT "ZSTD_BINARY=${ZSTD_BINARY}")
|
|
||||||
|
|
||||||
add_executable(test_dump_local_zstd test_dump_local_zstd.cpp)
|
add_test(NAME DumpXYZZstd COMMAND test_dump_xyz_compressed zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_link_libraries(test_dump_local_zstd PRIVATE lammps GTest::GMock GTest::GTest)
|
set_tests_properties(DumpXYZZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
|
||||||
add_test(NAME DumpLocalZstd COMMAND test_dump_local_zstd WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set_tests_properties(DumpLocalZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
|
||||||
set_tests_properties(DumpLocalZstd PROPERTIES ENVIRONMENT "ZSTD_BINARY=${ZSTD_BINARY}")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
107
unittest/formats/compressed_dump_test.h
Normal file
107
unittest/formats/compressed_dump_test.h
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://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.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
#ifndef TESTCASE_COMPRESSED_DUMP__H
|
||||||
|
#define TESTCASE_COMPRESSED_DUMP__H
|
||||||
|
|
||||||
|
#include "../testing/core.h"
|
||||||
|
#include "../testing/systems/melt.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
extern const char * COMPRESS_SUFFIX;
|
||||||
|
extern const char * COMPRESS_EXTENSION;
|
||||||
|
extern char * COMPRESS_BINARY;
|
||||||
|
|
||||||
|
class CompressedDumpTest : public MeltTest {
|
||||||
|
protected:
|
||||||
|
std::string dump_style;
|
||||||
|
std::string compression_style;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CompressedDumpTest(const std::string & dump_style) : MeltTest(), dump_style(dump_style) {
|
||||||
|
compression_style = fmt::format("{}/{}", dump_style, COMPRESS_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string text_dump_filename(std::string ident) {
|
||||||
|
return fmt::format("dump_{}_text_{}", COMPRESS_SUFFIX, ident);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string compressed_dump_filename(std::string ident) {
|
||||||
|
return fmt::format("dump_{}_compressed_{}.{}", COMPRESS_SUFFIX, ident, COMPRESS_EXTENSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string converted_dump_filename(std::string ident) {
|
||||||
|
return fmt::format("dump_{}_compressed_{}", COMPRESS_SUFFIX, ident);
|
||||||
|
}
|
||||||
|
|
||||||
|
void enable_triclinic()
|
||||||
|
{
|
||||||
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
command("change_box all triclinic");
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
|
||||||
|
{
|
||||||
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
|
||||||
|
|
||||||
|
if (!dump_modify_options.empty()) {
|
||||||
|
command(fmt::format("dump_modify id {}", dump_modify_options));
|
||||||
|
}
|
||||||
|
|
||||||
|
command(fmt::format("run {}", ntimesteps));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||||
|
std::string dump_options, std::string dump_modify_options, int ntimesteps)
|
||||||
|
{
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file,
|
||||||
|
dump_options, dump_options,
|
||||||
|
dump_modify_options, dump_modify_options, ntimesteps);
|
||||||
|
}
|
||||||
|
|
||||||
|
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||||
|
std::string text_options, std::string compressed_options,
|
||||||
|
std::string text_modify_options, std::string compressed_modify_options,
|
||||||
|
int ntimesteps)
|
||||||
|
{
|
||||||
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, text_options));
|
||||||
|
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, compressed_options));
|
||||||
|
|
||||||
|
if (!text_modify_options.empty()) {
|
||||||
|
command(fmt::format("dump_modify id0 {}", text_modify_options));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!compressed_modify_options.empty()) {
|
||||||
|
command(fmt::format("dump_modify id1 {}", compressed_modify_options));
|
||||||
|
}
|
||||||
|
|
||||||
|
command(fmt::format("run {}", ntimesteps));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string convert_compressed_to_text(std::string compressed_file)
|
||||||
|
{
|
||||||
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||||
|
std::string cmdline =
|
||||||
|
fmt::format("{} -d -c {} > {}", COMPRESS_BINARY, compressed_file, converted_file);
|
||||||
|
system(cmdline.c_str());
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
return converted_file;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
66
unittest/formats/compressed_dump_test_main.cpp
Normal file
66
unittest/formats/compressed_dump_test_main.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://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 "compressed_dump_test.h"
|
||||||
|
#include "../testing/utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
const char * COMPRESS_SUFFIX = nullptr;
|
||||||
|
const char * COMPRESS_EXTENSION = nullptr;
|
||||||
|
char * COMPRESS_BINARY = nullptr;
|
||||||
|
bool verbose = false;
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
MPI_Init(&argc, &argv);
|
||||||
|
::testing::InitGoogleMock(&argc, argv);
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
std::cerr << "usage: " << argv[0] << " (gz|zstd)\n\n" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strcmp(argv[1], "gz") == 0) {
|
||||||
|
COMPRESS_SUFFIX = "gz";
|
||||||
|
COMPRESS_EXTENSION = "gz";
|
||||||
|
} else if(strcmp(argv[1], "zstd") == 0) {
|
||||||
|
COMPRESS_SUFFIX = "zstd";
|
||||||
|
COMPRESS_EXTENSION = "zst";
|
||||||
|
} else {
|
||||||
|
std::cerr << "usage: " << argv[0] << " (gz|zstd)\n\n" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
COMPRESS_BINARY = getenv("COMPRESS_BINARY");
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
||||||
|
|
||||||
|
int rv = RUN_ALL_TESTS();
|
||||||
|
MPI_Finalize();
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
@ -24,6 +24,7 @@
|
|||||||
using ::testing::Eq;
|
using ::testing::Eq;
|
||||||
|
|
||||||
char *BINARY2TXT_BINARY = nullptr;
|
char *BINARY2TXT_BINARY = nullptr;
|
||||||
|
bool verbose = false;
|
||||||
|
|
||||||
class DumpAtomTest : public MeltTest {
|
class DumpAtomTest : public MeltTest {
|
||||||
std::string dump_style = "atom";
|
std::string dump_style = "atom";
|
||||||
|
|||||||
388
unittest/formats/test_dump_atom_compressed.cpp
Normal file
388
unittest/formats/test_dump_atom_compressed.cpp
Normal file
@ -0,0 +1,388 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
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/utils.h"
|
||||||
|
#include "compressed_dump_test.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
using ::testing::Eq;
|
||||||
|
|
||||||
|
class DumpAtomCompressTest : public CompressedDumpTest {
|
||||||
|
public:
|
||||||
|
DumpAtomCompressTest() : CompressedDumpTest("atom") {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
// compressed files
|
||||||
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEST_F(DumpAtomCompressTest, compressed_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto text_file = text_dump_filename("run0.melt");
|
||||||
|
auto compressed_file = compressed_dump_filename("run0.melt");
|
||||||
|
|
||||||
|
if(compression_style == "atom/zstd") {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "checksum yes", 0);
|
||||||
|
} else {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", 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("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();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_run1_*.melt";
|
||||||
|
auto base_name_0 = "multi_file_run1_0.melt";
|
||||||
|
auto base_name_1 = "multi_file_run1_1.melt";
|
||||||
|
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);
|
||||||
|
|
||||||
|
if(compression_style == "atom/zstd") {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "checksum no", 1);
|
||||||
|
} else {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", 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(DumpAtomCompressTest, compressed_multi_file_with_pad_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_pad_run1_*.melt";
|
||||||
|
auto base_name_0 = "multi_file_pad_run1_000.melt";
|
||||||
|
auto base_name_1 = "multi_file_pad_run1_001.melt";
|
||||||
|
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);
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "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(DumpAtomCompressTest, compressed_multi_file_with_maxfiles_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_maxfiles_run1_*.melt";
|
||||||
|
auto base_name_0 = "multi_file_maxfiles_run1_0.melt";
|
||||||
|
auto base_name_1 = "multi_file_maxfiles_run1_1.melt";
|
||||||
|
auto base_name_2 = "multi_file_maxfiles_run1_2.melt";
|
||||||
|
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);
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "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(DumpAtomCompressTest, compressed_with_units_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "with_units_run0.melt";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "scale no units yes", 0);
|
||||||
|
|
||||||
|
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(DumpAtomCompressTest, compressed_with_time_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "with_time_run0.melt";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "scale no time yes", 0);
|
||||||
|
|
||||||
|
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(DumpAtomCompressTest, compressed_triclinic_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "tri_run0.melt";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
enable_triclinic();
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", 0);
|
||||||
|
|
||||||
|
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(DumpAtomCompressTest, compressed_triclinic_with_units_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "tri_with_units_run0.melt";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
enable_triclinic();
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "scale no units yes", 0);
|
||||||
|
|
||||||
|
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(DumpAtomCompressTest, compressed_triclinic_with_time_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "tri_with_time_run0.melt";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
enable_triclinic();
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "scale no time yes", 0);
|
||||||
|
|
||||||
|
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(DumpAtomCompressTest, compressed_triclinic_with_image_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "tri_with_image_run0.melt";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
enable_triclinic();
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "image yes", 0);
|
||||||
|
|
||||||
|
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(DumpAtomCompressTest, compressed_modify_bad_param)
|
||||||
|
{
|
||||||
|
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")));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||||
|
command("dump_modify id1 compression_level 12");
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DumpAtomCompressTest, compressed_modify_multi_bad_param)
|
||||||
|
{
|
||||||
|
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")));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
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(DumpAtomCompressTest, compressed_modify_clevel_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "modify_clevel_run0.melt";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "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);
|
||||||
|
}
|
||||||
@ -1,277 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
char *GZIP_BINARY = nullptr;
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
class DumpAtomGZTest : public MeltTest {
|
|
||||||
std::string dump_style = "atom";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void enable_triclinic()
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command("change_box all triclinic");
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------
|
|
||||||
// GZ compressed files
|
|
||||||
//-------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
TEST_F(DumpAtomGZTest, compressed_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_gz_text_run0.melt";
|
|
||||||
auto compressed_file = "dump_gz_compressed_run0.melt.gz";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "", 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("dump_gz_compressed_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(DumpAtomGZTest, compressed_with_units_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_gz_text_with_units_run0.melt";
|
|
||||||
auto compressed_file = "dump_gz_compressed_with_units_run0.melt.gz";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes",
|
|
||||||
0);
|
|
||||||
|
|
||||||
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(DumpAtomGZTest, compressed_with_time_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_gz_text_with_time_run0.melt";
|
|
||||||
auto compressed_file = "dump_gz_compressed_with_time_run0.melt.gz";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes",
|
|
||||||
0);
|
|
||||||
|
|
||||||
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(DumpAtomGZTest, compressed_triclinic_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_gz_text_tri_run0.melt";
|
|
||||||
auto compressed_file = "dump_gz_compressed_tri_run0.melt.gz";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "", 0);
|
|
||||||
|
|
||||||
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(DumpAtomGZTest, compressed_triclinic_with_units_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_gz_text_tri_with_units_run0.melt";
|
|
||||||
auto compressed_file = "dump_gz_compressed_tri_with_units_run0.melt.gz";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes",
|
|
||||||
0);
|
|
||||||
|
|
||||||
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(DumpAtomGZTest, compressed_triclinic_with_time_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_gz_text_tri_with_time_run0.melt";
|
|
||||||
auto compressed_file = "dump_gz_compressed_tri_with_time_run0.melt.gz";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes",
|
|
||||||
0);
|
|
||||||
|
|
||||||
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(DumpAtomGZTest, compressed_triclinic_with_image_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_gz_text_tri_with_image_run0.melt";
|
|
||||||
auto compressed_file = "dump_gz_compressed_tri_with_image_run0.melt.gz";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "image yes", 0);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GZIP_BINARY = getenv("GZIP_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
@ -1,284 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
char *ZSTD_BINARY = nullptr;
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
class DumpAtomZSTDTest : public MeltTest {
|
|
||||||
std::string dump_style = "atom";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void enable_triclinic()
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command("change_box all triclinic");
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------
|
|
||||||
// ZSTD compressed files
|
|
||||||
//-------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
TEST_F(DumpAtomZSTDTest, compressed_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_zstd_text_run0.melt";
|
|
||||||
auto compressed_file = "dump_zstd_compressed_run0.melt.zst";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "", 0);
|
|
||||||
|
|
||||||
// make sure file is closed
|
|
||||||
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("dump_zstd_compressed_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(DumpAtomZSTDTest, compressed_with_units_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_zstd_text_with_units_run0.melt";
|
|
||||||
auto compressed_file = "dump_zstd_compressed_with_units_run0.melt.zst";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no units yes",
|
|
||||||
0);
|
|
||||||
|
|
||||||
// make sure file is closed
|
|
||||||
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(DumpAtomZSTDTest, compressed_with_time_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_zstd_text_with_time_run0.melt";
|
|
||||||
auto compressed_file = "dump_zstd_compressed_with_time_run0.melt.zst";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no time yes",
|
|
||||||
0);
|
|
||||||
|
|
||||||
// make sure file is closed
|
|
||||||
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(DumpAtomZSTDTest, compressed_triclinic_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_zstd_text_tri_run0.melt";
|
|
||||||
auto compressed_file = "dump_zstd_compressed_tri_run0.melt.zst";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "", 0);
|
|
||||||
|
|
||||||
// make sure file is closed
|
|
||||||
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(DumpAtomZSTDTest, compressed_triclinic_with_units_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_zstd_text_tri_with_units_run0.melt";
|
|
||||||
auto compressed_file = "dump_zstd_compressed_tri_with_units_run0.melt.zst";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no units yes",
|
|
||||||
0);
|
|
||||||
|
|
||||||
// make sure file is closed
|
|
||||||
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(DumpAtomZSTDTest, compressed_triclinic_with_time_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_zstd_text_tri_with_time_run0.melt";
|
|
||||||
auto compressed_file = "dump_zstd_compressed_tri_with_time_run0.melt.zst";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no time yes",
|
|
||||||
0);
|
|
||||||
|
|
||||||
// make sure file is closed
|
|
||||||
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(DumpAtomZSTDTest, compressed_triclinic_with_image_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_zstd_text_tri_with_image_run0.melt";
|
|
||||||
auto compressed_file = "dump_zstd_compressed_tri_with_image_run0.melt.zst";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "image yes", 0);
|
|
||||||
|
|
||||||
// make sure file is closed
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ZSTD_BINARY = getenv("ZSTD_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
using ::testing::Eq;
|
using ::testing::Eq;
|
||||||
|
|
||||||
|
bool verbose = false;
|
||||||
|
|
||||||
class DumpCfgTest : public MeltTest {
|
class DumpCfgTest : public MeltTest {
|
||||||
std::string dump_style = "cfg";
|
std::string dump_style = "cfg";
|
||||||
|
|
||||||
|
|||||||
283
unittest/formats/test_dump_cfg_compressed.cpp
Normal file
283
unittest/formats/test_dump_cfg_compressed.cpp
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
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/utils.h"
|
||||||
|
#include "compressed_dump_test.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
using ::testing::Eq;
|
||||||
|
|
||||||
|
class DumpCfgCompressTest : public CompressedDumpTest {
|
||||||
|
public:
|
||||||
|
DumpCfgCompressTest() : CompressedDumpTest("cfg") {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
// compressed files
|
||||||
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEST_F(DumpCfgCompressTest, compressed_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "run*.melt.cfg";
|
||||||
|
auto text_files = text_dump_filename(base_name);
|
||||||
|
auto compressed_files = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
auto base_name_0 = "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, "", "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(DumpCfgCompressTest, compressed_unwrap_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "unwrap_run*.melt.cfg";
|
||||||
|
auto text_files = text_dump_filename(base_name);
|
||||||
|
auto compressed_files = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
auto base_name_0 = "unwrap_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 xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||||
|
|
||||||
|
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(DumpCfgCompressTest, compressed_multi_file_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_run1_*.melt.cfg";
|
||||||
|
auto base_name_0 = "multi_file_run1_0.melt.cfg";
|
||||||
|
auto base_name_1 = "multi_file_run1_1.melt.cfg";
|
||||||
|
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 = "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_file, compressed_file, fields, fields, "", "checksum no", 1);
|
||||||
|
} else {
|
||||||
|
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(DumpCfgCompressTest, compressed_multi_file_with_pad_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_pad_run1_*.melt.cfg";
|
||||||
|
auto base_name_0 = "multi_file_pad_run1_000.melt.cfg";
|
||||||
|
auto base_name_1 = "multi_file_pad_run1_001.melt.cfg";
|
||||||
|
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 = "mass type xs ys zs id proc procp1 x y z ix iy iz 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(DumpCfgCompressTest, compressed_multi_file_with_maxfiles_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_maxfiles_run1_*.melt.cfg";
|
||||||
|
auto base_name_0 = "multi_file_maxfiles_run1_0.melt.cfg";
|
||||||
|
auto base_name_1 = "multi_file_maxfiles_run1_1.melt.cfg";
|
||||||
|
auto base_name_2 = "multi_file_maxfiles_run1_2.melt.cfg";
|
||||||
|
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 = "mass type xs ys zs id proc procp1 x y z ix iy iz 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(DumpCfgCompressTest, compressed_modify_bad_param)
|
||||||
|
{
|
||||||
|
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";
|
||||||
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
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.*",
|
||||||
|
command("dump_modify id1 compression_level 12");
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DumpCfgCompressTest, compressed_modify_multi_bad_param)
|
||||||
|
{
|
||||||
|
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";
|
||||||
|
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));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
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(DumpCfgCompressTest, compressed_modify_clevel_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "modify_clevel_run*.melt.cfg";
|
||||||
|
auto base_name_0 = "modify_clevel_run0.melt.cfg";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = 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 = "mass type xs ys zs id proc procp1 x y z ix iy iz 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_0);
|
||||||
|
ASSERT_FILE_EXISTS(compressed_file_0);
|
||||||
|
|
||||||
|
auto converted_file_0 = convert_compressed_to_text(compressed_file);
|
||||||
|
|
||||||
|
ASSERT_THAT(converted_file_0, Eq(converted_dump_filename(base_name)));
|
||||||
|
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);
|
||||||
|
}
|
||||||
@ -1,133 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
char *GZIP_BINARY = nullptr;
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
class DumpCfgGZTest : public MeltTest {
|
|
||||||
std::string dump_style = "cfg";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style, std::string fields,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DumpCfgGZTest, compressed_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_files = "dump_cfg_gz_text_run*.melt.cfg";
|
|
||||||
auto compressed_files = "dump_cfg_gz_compressed_run*.melt.cfg.gz";
|
|
||||||
auto text_file = "dump_cfg_gz_text_run0.melt.cfg";
|
|
||||||
auto compressed_file = "dump_cfg_gz_compressed_run0.melt.cfg.gz";
|
|
||||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_files, compressed_files, "cfg/gz", fields, "", 0);
|
|
||||||
|
|
||||||
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(DumpCfgGZTest, compressed_unwrap_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_files = "dump_cfg_unwrap_gz_text_run*.melt.cfg";
|
|
||||||
auto compressed_files = "dump_cfg_unwrap_gz_compressed_run*.melt.cfg.gz";
|
|
||||||
auto text_file = "dump_cfg_unwrap_gz_text_run0.melt.cfg";
|
|
||||||
auto compressed_file = "dump_cfg_unwrap_gz_compressed_run0.melt.cfg.gz";
|
|
||||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_files, compressed_files, "cfg/gz", fields, "", 0);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GZIP_BINARY = getenv("GZIP_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
@ -1,133 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
char *ZSTD_BINARY = nullptr;
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
class DumpCfgZstdTest : public MeltTest {
|
|
||||||
std::string dump_style = "cfg";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style, std::string fields,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DumpCfgZstdTest, compressed_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_files = "dump_cfg_zstd_text_run*.melt.cfg";
|
|
||||||
auto compressed_files = "dump_cfg_zstd_compressed_run*.melt.cfg.zst";
|
|
||||||
auto text_file = "dump_cfg_zstd_text_run0.melt.cfg";
|
|
||||||
auto compressed_file = "dump_cfg_zstd_compressed_run0.melt.cfg.zst";
|
|
||||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_files, compressed_files, "cfg/zstd", fields, "", 0);
|
|
||||||
|
|
||||||
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(DumpCfgZstdTest, compressed_unwrap_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_files = "dump_cfg_unwrap_zstd_text_run*.melt.cfg";
|
|
||||||
auto compressed_files = "dump_cfg_unwrap_zstd_compressed_run*.melt.cfg.zst";
|
|
||||||
auto text_file = "dump_cfg_unwrap_zstd_text_run0.melt.cfg";
|
|
||||||
auto compressed_file = "dump_cfg_unwrap_zstd_compressed_run0.melt.cfg.zst";
|
|
||||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_files, compressed_files, "cfg/zstd", fields, "", 0);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ZSTD_BINARY = getenv("ZSTD_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
@ -22,6 +22,7 @@
|
|||||||
using ::testing::Eq;
|
using ::testing::Eq;
|
||||||
|
|
||||||
char *BINARY2TXT_BINARY = nullptr;
|
char *BINARY2TXT_BINARY = nullptr;
|
||||||
|
bool verbose = false;
|
||||||
|
|
||||||
class DumpCustomTest : public MeltTest {
|
class DumpCustomTest : public MeltTest {
|
||||||
std::string dump_style = "custom";
|
std::string dump_style = "custom";
|
||||||
|
|||||||
266
unittest/formats/test_dump_custom_compressed.cpp
Normal file
266
unittest/formats/test_dump_custom_compressed.cpp
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
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/utils.h"
|
||||||
|
#include "compressed_dump_test.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
using ::testing::Eq;
|
||||||
|
|
||||||
|
class DumpCustomCompressTest : public CompressedDumpTest {
|
||||||
|
public:
|
||||||
|
DumpCustomCompressTest() : CompressedDumpTest("custom") {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(DumpCustomCompressTest, compressed_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "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, "units yes", "units yes checksum yes", 1);
|
||||||
|
} else {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, fields, "units 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_triclinic_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "custom_tri_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 xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
||||||
|
|
||||||
|
enable_triclinic();
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, fields, "units 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_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";
|
||||||
|
|
||||||
|
if(compression_style == "custom/zstd") {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "checksum no", 1);
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
@ -1,154 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
char *GZIP_BINARY = nullptr;
|
|
||||||
|
|
||||||
class DumpCustomGZTest : public MeltTest {
|
|
||||||
std::string dump_style = "custom";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void enable_triclinic()
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command("change_box all triclinic");
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
|
|
||||||
int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style, std::string fields,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DumpCustomGZTest, compressed_run1)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_custom_gz_text_run1.melt";
|
|
||||||
auto compressed_file = "dump_custom_gz_compressed_run1.melt.gz";
|
|
||||||
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, "custom/gz", fields, "units 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(DumpCustomGZTest, compressed_triclinic_run1)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_custom_gz_tri_text_run1.melt";
|
|
||||||
auto compressed_file = "dump_custom_gz_tri_compressed_run1.melt.gz";
|
|
||||||
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/gz", fields, "units 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GZIP_BINARY = getenv("GZIP_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
@ -1,154 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
char *ZSTD_BINARY = nullptr;
|
|
||||||
|
|
||||||
class DumpCustomZstdTest : public MeltTest {
|
|
||||||
std::string dump_style = "custom";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void enable_triclinic()
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command("change_box all triclinic");
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
|
|
||||||
int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style, std::string fields,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DumpCustomZstdTest, compressed_run1)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_custom_zstd_text_run1.melt";
|
|
||||||
auto compressed_file = "dump_custom_zstd_compressed_run1.melt.zst";
|
|
||||||
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, "custom/zstd", fields,
|
|
||||||
"units 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(DumpCustomZstdTest, compressed_triclinic_run1)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_file = "dump_custom_zstd_tri_text_run1.melt";
|
|
||||||
auto compressed_file = "dump_custom_zstd_tri_compressed_run1.melt.zst";
|
|
||||||
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
|
||||||
|
|
||||||
enable_triclinic();
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/zstd", fields,
|
|
||||||
"units 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ZSTD_BINARY = getenv("ZSTD_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
256
unittest/formats/test_dump_local_compressed.cpp
Normal file
256
unittest/formats/test_dump_local_compressed.cpp
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
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/utils.h"
|
||||||
|
#include "compressed_dump_test.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
using ::testing::Eq;
|
||||||
|
|
||||||
|
class DumpLocalCompressTest : public CompressedDumpTest {
|
||||||
|
public:
|
||||||
|
DumpLocalCompressTest() : CompressedDumpTest("local") {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
CompressedDumpTest::SetUp();
|
||||||
|
|
||||||
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
command("compute comp all pair/local dist eng");
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(DumpLocalCompressTest, compressed_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "run*.melt.local";
|
||||||
|
auto base_name_0 = "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();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_run1_*.melt.local";
|
||||||
|
auto base_name_0 = "multi_file_run1_0.melt.local";
|
||||||
|
auto base_name_1 = "multi_file_run1_1.melt.local";
|
||||||
|
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 = "index c_comp[1]";
|
||||||
|
|
||||||
|
if(compression_style == "local/zstd") {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "checksum no", 1);
|
||||||
|
} else {
|
||||||
|
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(DumpLocalCompressTest, compressed_multi_file_with_pad_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_pad_run1_*.melt.local";
|
||||||
|
auto base_name_0 = "multi_file_pad_run1_000.melt.local";
|
||||||
|
auto base_name_1 = "multi_file_pad_run1_001.melt.local";
|
||||||
|
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 = "index c_comp[1]";
|
||||||
|
|
||||||
|
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(DumpLocalCompressTest, compressed_multi_file_with_maxfiles_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_maxfiles_run1_*.melt.local";
|
||||||
|
auto base_name_0 = "multi_file_maxfiles_run1_0.melt.local";
|
||||||
|
auto base_name_1 = "multi_file_maxfiles_run1_1.melt.local";
|
||||||
|
auto base_name_2 = "multi_file_maxfiles_run1_2.melt.local";
|
||||||
|
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 = "index c_comp[1]";
|
||||||
|
|
||||||
|
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(DumpLocalCompressTest, compressed_modify_bad_param)
|
||||||
|
{
|
||||||
|
if (compression_style != "local/gz") GTEST_SKIP();
|
||||||
|
|
||||||
|
auto fields = "index c_comp[1]";
|
||||||
|
|
||||||
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.local"), fields));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||||
|
command("dump_modify id1 compression_level 12");
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DumpLocalCompressTest, compressed_modify_multi_bad_param)
|
||||||
|
{
|
||||||
|
if (compression_style != "local/gz") GTEST_SKIP();
|
||||||
|
|
||||||
|
auto fields = "index c_comp[1]";
|
||||||
|
|
||||||
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.local"), fields));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
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(DumpLocalCompressTest, compressed_modify_clevel_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "modify_clevel_run0.melt.local";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
auto fields = "index c_comp[1]";
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
@ -1,111 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
char *GZIP_BINARY = nullptr;
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
class DumpLocalGZTest : public MeltTest {
|
|
||||||
std::string dump_style = "local";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style, std::string fields,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DumpLocalGZTest, compressed_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command("compute comp all pair/local dist eng");
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
|
|
||||||
auto text_files = "dump_local_gz_text_run*.melt.local";
|
|
||||||
auto compressed_files = "dump_local_gz_compressed_run*.melt.local.gz";
|
|
||||||
auto text_file = "dump_local_gz_text_run0.melt.local";
|
|
||||||
auto compressed_file = "dump_local_gz_compressed_run0.melt.local.gz";
|
|
||||||
auto fields = "index c_comp[1]";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_files, compressed_files, "local/gz", fields, "", 0);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GZIP_BINARY = getenv("GZIP_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
@ -1,111 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
char *ZSTD_BINARY = nullptr;
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
class DumpLocalGZTest : public MeltTest {
|
|
||||||
std::string dump_style = "local";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style, std::string fields,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DumpLocalGZTest, compressed_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command("compute comp all pair/local dist eng");
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
|
|
||||||
auto text_files = "dump_local_zstd_text_run*.melt.local";
|
|
||||||
auto compressed_files = "dump_local_zstd_compressed_run*.melt.local.zst";
|
|
||||||
auto text_file = "dump_local_zstd_text_run0.melt.local";
|
|
||||||
auto compressed_file = "dump_local_zstd_compressed_run0.melt.local.zst";
|
|
||||||
auto fields = "index c_comp[1]";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_files, compressed_files, "local/zstd", fields, "", 0);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ZSTD_BINARY = getenv("ZSTD_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
239
unittest/formats/test_dump_xyz_compressed.cpp
Normal file
239
unittest/formats/test_dump_xyz_compressed.cpp
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
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/utils.h"
|
||||||
|
#include "compressed_dump_test.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
using ::testing::Eq;
|
||||||
|
|
||||||
|
class DumpXYZCompressTest : public CompressedDumpTest {
|
||||||
|
public:
|
||||||
|
DumpXYZCompressTest() : CompressedDumpTest("xyz") {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(DumpXYZCompressTest, compressed_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "run*.melt.xyz";
|
||||||
|
auto base_name_0 = "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, "", "", "", "checksum yes", 0);
|
||||||
|
} else {
|
||||||
|
generate_text_and_compressed_dump(text_files, compressed_files, "", "", 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();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_run1_*.melt.xyz";
|
||||||
|
auto base_name_0 = "multi_file_run1_0.melt.xyz";
|
||||||
|
auto base_name_1 = "multi_file_run1_1.melt.xyz";
|
||||||
|
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);
|
||||||
|
|
||||||
|
if(compression_style == "xyz/zstd") {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "checksum no", 1);
|
||||||
|
} else {
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", 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(DumpXYZCompressTest, compressed_multi_file_with_pad_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_pad_run1_*.melt.xyz";
|
||||||
|
auto base_name_0 = "multi_file_pad_run1_000.melt.xyz";
|
||||||
|
auto base_name_1 = "multi_file_pad_run1_001.melt.xyz";
|
||||||
|
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);
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "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(DumpXYZCompressTest, compressed_multi_file_with_maxfiles_run1)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "multi_file_maxfiles_run1_*.melt.xyz";
|
||||||
|
auto base_name_0 = "multi_file_maxfiles_run1_0.melt.xyz";
|
||||||
|
auto base_name_1 = "multi_file_maxfiles_run1_1.melt.xyz";
|
||||||
|
auto base_name_2 = "multi_file_maxfiles_run1_2.melt.xyz";
|
||||||
|
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);
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "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(DumpXYZCompressTest, compressed_modify_bad_param)
|
||||||
|
{
|
||||||
|
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")));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
|
||||||
|
command("dump_modify id1 compression_level 12");
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DumpXYZCompressTest, compressed_modify_multi_bad_param)
|
||||||
|
{
|
||||||
|
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")));
|
||||||
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
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(DumpXYZCompressTest, compressed_modify_clevel_run0)
|
||||||
|
{
|
||||||
|
if (!COMPRESS_BINARY) GTEST_SKIP();
|
||||||
|
|
||||||
|
auto base_name = "modify_clevel_run0.melt.xyz";
|
||||||
|
auto text_file = text_dump_filename(base_name);
|
||||||
|
auto compressed_file = compressed_dump_filename(base_name);
|
||||||
|
|
||||||
|
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "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);
|
||||||
|
}
|
||||||
@ -1,106 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
char *GZIP_BINARY = nullptr;
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
class DumpXYZGZTest : public MeltTest {
|
|
||||||
std::string dump_style = "xyz";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DumpXYZGZTest, compressed_run0)
|
|
||||||
{
|
|
||||||
if (!GZIP_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_files = "dump_xyz_gz_text_run*.melt.xyz";
|
|
||||||
auto compressed_files = "dump_xyz_gz_compressed_run*.melt.xyz.gz";
|
|
||||||
auto text_file = "dump_xyz_gz_text_run0.melt.xyz";
|
|
||||||
auto compressed_file = "dump_xyz_gz_compressed_run0.melt.xyz.gz";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_files, compressed_files, "xyz/gz", "", 0);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GZIP_BINARY = getenv("GZIP_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
@ -1,106 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
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 "utils.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
char *ZSTD_BINARY = nullptr;
|
|
||||||
|
|
||||||
using ::testing::Eq;
|
|
||||||
|
|
||||||
class DumpXYZGZTest : public MeltTest {
|
|
||||||
std::string dump_style = "xyz";
|
|
||||||
|
|
||||||
public:
|
|
||||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
|
||||||
std::string compression_style,
|
|
||||||
std::string dump_modify_options, int ntimesteps)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
|
||||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
|
|
||||||
|
|
||||||
if (!dump_modify_options.empty()) {
|
|
||||||
command(fmt::format("dump_modify id0 {}", dump_modify_options));
|
|
||||||
command(fmt::format("dump_modify id1 {}", dump_modify_options));
|
|
||||||
}
|
|
||||||
|
|
||||||
command(fmt::format("run {}", ntimesteps));
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string convert_compressed_to_text(std::string compressed_file)
|
|
||||||
{
|
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
|
||||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
|
||||||
std::string cmdline =
|
|
||||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
|
||||||
system(cmdline.c_str());
|
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
|
||||||
return converted_file;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DumpXYZGZTest, compressed_run0)
|
|
||||||
{
|
|
||||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
|
||||||
|
|
||||||
auto text_files = "dump_xyz_zstd_text_run*.melt.xyz";
|
|
||||||
auto compressed_files = "dump_xyz_zstd_compressed_run*.melt.xyz.zst";
|
|
||||||
auto text_file = "dump_xyz_zstd_text_run0.melt.xyz";
|
|
||||||
auto compressed_file = "dump_xyz_zstd_compressed_run0.melt.xyz.zst";
|
|
||||||
|
|
||||||
generate_text_and_compressed_dump(text_files, compressed_files, "xyz/zstd", "", 0);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ZSTD_BINARY = getenv("ZSTD_BINARY");
|
|
||||||
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
|
||||||
|
|
||||||
int rv = RUN_ALL_TESTS();
|
|
||||||
MPI_Finalize();
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
@ -42,7 +42,7 @@ using ::testing::MatchesRegex;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
||||||
bool verbose = false;
|
extern bool verbose;
|
||||||
|
|
||||||
class LAMMPSTest : public ::testing::Test {
|
class LAMMPSTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -70,6 +70,9 @@ static bool file_exists(const std::string &filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ASSERT_FILE_EXISTS(NAME) ASSERT_TRUE(file_exists(NAME))
|
#define ASSERT_FILE_EXISTS(NAME) ASSERT_TRUE(file_exists(NAME))
|
||||||
|
#define ASSERT_FILE_NOT_EXISTS(NAME) ASSERT_FALSE(file_exists(NAME))
|
||||||
#define ASSERT_FILE_EQUAL(FILE_A, FILE_B) ASSERT_TRUE(equal_lines(FILE_A, FILE_B))
|
#define ASSERT_FILE_EQUAL(FILE_A, FILE_B) ASSERT_TRUE(equal_lines(FILE_A, FILE_B))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user