Skip to content

Commit fa2700a

Browse files
committed
Testing
1 parent 1ed11d5 commit fa2700a

File tree

3 files changed

+161
-5
lines changed

3 files changed

+161
-5
lines changed

test/CoreTest.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,12 +1074,24 @@ TEST_CASE("backend_via_json", "[core]")
10741074
* BP4 engine should be selected even if ending .sst is given
10751075
*/
10761076
Series series(
1077-
"../samples/optionsViaJsonOverwritesAutomaticDetection.sst",
1077+
"../samples/optionsViaJsonOverwritesAutomaticDetectionFile.sst",
1078+
Access::CREATE,
1079+
R"({"adios2": {"engine": {"type": "file"}}})");
1080+
}
1081+
REQUIRE(auxiliary::directory_exists(
1082+
"../samples/optionsViaJsonOverwritesAutomaticDetectionFile.sst"));
1083+
1084+
{
1085+
/*
1086+
* BP4 engine should be selected even if ending .sst is given
1087+
*/
1088+
Series series(
1089+
"../samples/optionsViaJsonOverwritesAutomaticDetectionBp4.sst",
10781090
Access::CREATE,
10791091
R"({"adios2": {"engine": {"type": "bp4"}}})");
10801092
}
10811093
REQUIRE(auxiliary::directory_exists(
1082-
"../samples/optionsViaJsonOverwritesAutomaticDetection.bp"));
1094+
"../samples/optionsViaJsonOverwritesAutomaticDetectionBp4.sst"));
10831095

10841096
#if openPMD_HAVE_ADIOS1
10851097
setenv("OPENPMD_BP_BACKEND", "ADIOS1", 1);

test/ParallelIOTest.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,10 @@ void adios2_streaming(bool variableBasedLayout)
10661066
if (rank == 0)
10671067
{
10681068
// write
1069-
Series writeSeries("../samples/adios2_stream.sst", Access::CREATE);
1069+
Series writeSeries(
1070+
"../samples/adios2_stream.sst",
1071+
Access::CREATE,
1072+
"adios2.engine.type = \"sst\"");
10701073
if (variableBasedLayout)
10711074
{
10721075
writeSeries.setIterationEncoding(IterationEncoding::variableBased);
@@ -1109,7 +1112,8 @@ void adios2_streaming(bool variableBasedLayout)
11091112
Series readSeries(
11101113
"../samples/adios2_stream.sst",
11111114
Access::READ_ONLY,
1112-
"defer_iteration_parsing = true"); // inline TOML
1115+
// inline TOML
1116+
R"(defer_iteration_parsing = true)");
11131117

11141118
size_t last_iteration_index = 0;
11151119
for (auto iteration : readSeries.readIterations())

test/SerialIOTest.cpp

Lines changed: 141 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ std::vector<BackendSelection> testedBackends()
4747
{
4848
auto variants = getVariants();
4949
std::map<std::string, std::string> extensions{
50-
{"json", "json"}, {"adios1", "bp1"}, {"adios2", "bp"}, {"hdf5", "h5"}};
50+
{"json", "json"},
51+
{"adios1", "adios1.bp"},
52+
{"adios2", "bp"},
53+
{"hdf5", "h5"}};
5154
std::vector<BackendSelection> res;
5255
for (auto const &pair : variants)
5356
{
@@ -3925,6 +3928,143 @@ TEST_CASE("git_adios2_early_chunk_query", "[serial][adios2]")
39253928
R"({"backend": "adios2"})");
39263929
}
39273930

3931+
TEST_CASE("adios2_engines_and_file_endings")
3932+
{
3933+
size_t filenameCounter = 0;
3934+
auto groupbased_test = [&filenameCounter](
3935+
std::string const &ext,
3936+
bool directory,
3937+
std::string const &requiredEngine,
3938+
std::string const &filesystemExt,
3939+
std::string const &jsonCfg = "{}") mutable {
3940+
auto basename = "../samples/file_endings/groupbased" +
3941+
std::to_string(filenameCounter++);
3942+
auto name = basename + ext;
3943+
auto filesystemname =
3944+
filesystemExt.empty() ? name : basename + filesystemExt;
3945+
{
3946+
Series write(
3947+
name,
3948+
Access::CREATE,
3949+
json::merge(
3950+
"backend = \"adios2\"\nadios2.engine.usesteps = true",
3951+
jsonCfg));
3952+
}
3953+
if (directory)
3954+
{
3955+
REQUIRE(auxiliary::directory_exists(filesystemname));
3956+
}
3957+
else
3958+
{
3959+
REQUIRE(auxiliary::file_exists(filesystemname));
3960+
}
3961+
{
3962+
Series read(
3963+
name,
3964+
Access::READ_ONLY,
3965+
"backend = \"adios2\"\nadios2.engine.usesteps = "
3966+
"true\nadios2.engine.type = \"" +
3967+
requiredEngine + "\"");
3968+
}
3969+
};
3970+
3971+
groupbased_test(".bp", true, "file", "");
3972+
groupbased_test(".bp4", true, "bp4", "");
3973+
groupbased_test(".bp", true, "bp4", "", "adios2.engine.type = \"bp4\"");
3974+
groupbased_test(".bp4", true, "bp4", "", "adios2.engine.type = \"bp4\"");
3975+
groupbased_test(".bp5", true, "bp4", "", "adios2.engine.type = \"bp4\"");
3976+
groupbased_test(".bp", false, "bp3", "", "adios2.engine.type = \"bp3\"");
3977+
groupbased_test(
3978+
".sst", false, "bp3", ".sst.bp", "adios2.engine.type = \"bp3\"");
3979+
groupbased_test(
3980+
".bp3", false, "bp3", ".bp3.bp", "adios2.engine.type = \"bp3\"");
3981+
groupbased_test("", false, "bp3", ".bp", "adios2.engine.type = \"bp3\"");
3982+
groupbased_test("", true, "bp4", "", "adios2.engine.type = \"bp4\"");
3983+
3984+
#if ADIOS2_VERSION_MAJOR * 1000000000 + ADIOS2_VERSION_MINOR * 100000000 + \
3985+
ADIOS2_VERSION_PATCH * 1000000 + ADIOS2_VERSION_TWEAK >= \
3986+
2701001223
3987+
// BP5 tests
3988+
groupbased_test(".bp5", true, "bp5", "");
3989+
groupbased_test(".bp", true, "bp5", "", "adios2.engine.type = \"bp5\"");
3990+
groupbased_test(".bp4", true, "bp5", "", "adios2.engine.type = \"bp5\"");
3991+
groupbased_test(".bp5", true, "bp5", "", "adios2.engine.type = \"bp5\"");
3992+
groupbased_test("", true, "bp5", "", "adios2.engine.type = \"bp5\"");
3993+
#endif
3994+
3995+
filenameCounter = 0;
3996+
auto filebased_test = [&filenameCounter](
3997+
std::string const &ext,
3998+
bool directory,
3999+
std::string const &requiredEngine,
4000+
std::string const &filesystemExt,
4001+
std::string const &jsonCfg = "{}") mutable {
4002+
auto basename = "../samples/file_endings/filebased" +
4003+
std::to_string(filenameCounter++);
4004+
auto name = basename + "_%T" + ext;
4005+
auto filesystemname =
4006+
basename + "_0" + (filesystemExt.empty() ? ext : filesystemExt);
4007+
{
4008+
Series write(
4009+
name,
4010+
Access::CREATE,
4011+
json::merge(
4012+
"backend = \"adios2\"\nadios2.engine.usesteps = true",
4013+
jsonCfg));
4014+
write.writeIterations()[0];
4015+
}
4016+
if (directory)
4017+
{
4018+
REQUIRE(auxiliary::directory_exists(filesystemname));
4019+
}
4020+
else
4021+
{
4022+
REQUIRE(auxiliary::file_exists(filesystemname));
4023+
}
4024+
{
4025+
if (requiredEngine == "bp3" && !auxiliary::ends_with(name, ".bp"))
4026+
{
4027+
/*
4028+
* File-based parsing procedures are not aware that BP3 engine
4029+
* adds its ending and won't find the iterations if we don't
4030+
* give it a little nudge.
4031+
*/
4032+
name += ".bp";
4033+
}
4034+
Series read(
4035+
name,
4036+
Access::READ_ONLY,
4037+
"backend = \"adios2\"\nadios2.engine.usesteps = "
4038+
"true\nadios2.engine.type = \"" +
4039+
requiredEngine + "\"");
4040+
}
4041+
};
4042+
4043+
filebased_test(".bp", true, "file", "");
4044+
filebased_test(".bp4", true, "bp4", "");
4045+
filebased_test(".bp", true, "bp4", "", "adios2.engine.type = \"bp4\"");
4046+
filebased_test(".bp4", true, "bp4", "", "adios2.engine.type = \"bp4\"");
4047+
filebased_test(".bp5", true, "bp4", "", "adios2.engine.type = \"bp4\"");
4048+
filebased_test(".bp", false, "bp3", "", "adios2.engine.type = \"bp3\"");
4049+
filebased_test(
4050+
".sst", false, "bp3", ".sst.bp", "adios2.engine.type = \"bp3\"");
4051+
filebased_test(
4052+
".bp3", false, "bp3", ".bp3.bp", "adios2.engine.type = \"bp3\"");
4053+
filebased_test("", false, "bp3", ".bp", "adios2.engine.type = \"bp3\"");
4054+
filebased_test("", true, "bp4", "", "adios2.engine.type = \"bp4\"");
4055+
4056+
#if ADIOS2_VERSION_MAJOR * 1000000000 + ADIOS2_VERSION_MINOR * 100000000 + \
4057+
ADIOS2_VERSION_PATCH * 1000000 + ADIOS2_VERSION_TWEAK >= \
4058+
2701001223
4059+
// BP5 tests
4060+
filebased_test(".bp5", true, "bp5", "");
4061+
filebased_test(".bp", true, "bp5", "", "adios2.engine.type = \"bp5\"");
4062+
filebased_test(".bp4", true, "bp5", "", "adios2.engine.type = \"bp5\"");
4063+
filebased_test(".bp5", true, "bp5", "", "adios2.engine.type = \"bp5\"");
4064+
filebased_test("", true, "bp5", "", "adios2.engine.type = \"bp5\"");
4065+
#endif
4066+
}
4067+
39284068
TEST_CASE("serial_adios2_backend_config", "[serial][adios2]")
39294069
{
39304070
if (auxiliary::getEnvString("OPENPMD_BP_BACKEND", "NOT_SET") == "ADIOS1")

0 commit comments

Comments
 (0)