Skip to content

Commit

Permalink
Extend this test to variable-based
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Mar 28, 2022
1 parent df4d106 commit 5a5275f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/Iteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,18 @@ void Iteration::read_impl(std::string const &groupPath)
}

readAttributes(ReadMode::FullyReread);
// @todo put this in cmake
#define DEBUG 1
#if DEBUG
if (containsAttribute("__openPMD_internal_fail"))
{
throw error::ReadError(
error::AffectedObject::Attribute,
error::Reason::Other,
{},
"Deliberately failing this iteration for testing purposes");
}
#endif
}

AdvanceStatus Iteration::beginStep()
Expand Down
18 changes: 13 additions & 5 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5484,12 +5484,15 @@ TEST_CASE("no_explicit_flush", "[serial]")
}
}

void unfinished_iteration_test(std::string const &file)
void unfinished_iteration_test(
std::string const &ext, bool filebased, std::string const &config = "{}")
{
std::string file = std::string("../samples/unfinished_iteration.") +
(filebased ? "_%T." : "") + ext;
{
Series write(file, Access::CREATE);
Series write(file, Access::CREATE, config);
auto it0 = write.writeIterations()[0];
it0.setAttribute("dt", "This is wrong.");
it0.setAttribute("__openPMD_internal_fail", "asking for trouble");
auto it10 = write.writeIterations()[10];
auto E_x = it10.meshes["E"]["x"];
auto e_density = it10.meshes["e_density"][RecordComponent::SCALAR];
Expand All @@ -5505,9 +5508,14 @@ void unfinished_iteration_test(std::string const &file)
TEST_CASE("unfinished_iteration_test", "[serial]")
{
#if openPMD_HAVE_ADIOS2
unfinished_iteration_test("../samples/unfinished_iteration.bp");
unfinished_iteration_test("bp", false);
unfinished_iteration_test(
"../samples/unfinished_iteration_filebased_%T.bp");
"bp",
false,
R"(
iteration_encoding = "variable_based"
adios2.schema = 20210209)");
unfinished_iteration_test("bp", true);
#endif
}

Expand Down

0 comments on commit 5a5275f

Please sign in to comment.