Skip to content

Commit 953a29a

Browse files
committed
Add test: weird order of iterations
1 parent 897e5bc commit 953a29a

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

src/Series.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,10 +1511,12 @@ SeriesInternal::~SeriesInternal()
15111511
// we must not throw in a destructor
15121512
try
15131513
{
1514+
// give WriteIterations the chance to flush first
1515+
m_writeIterations = auxiliary::Option< WriteIterations >();
15141516
/*
1515-
* Scenario: A user calls `Series::flush()` but does not check for thrown
1516-
* exceptions. The exception will propagate further up, usually thereby
1517-
* popping the stack frame that holds the `Series` object.
1517+
* Scenario: A user calls `Series::flush()` but does not check for
1518+
* thrown exceptions. The exception will propagate further up, usually
1519+
* thereby popping the stack frame that holds the `Series` object.
15181520
* `Series::~Series()` will run. This check avoids that the `Series` is
15191521
* needlessly flushed a second time. Otherwise, error messages can get
15201522
* very confusing.

test/SerialIOTest.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,3 +4302,75 @@ TEST_CASE( "deferred_parsing", "[serial]" )
43024302
deferred_parsing( t );
43034303
}
43044304
}
4305+
4306+
void chaotic_stream( std::string filename, bool variableBased )
4307+
{
4308+
std::vector< uint64_t > iterations{ 5, 9, 1, 3, 4, 6, 7, 8, 2, 0 };
4309+
std::string jsonConfig = R"(
4310+
{
4311+
"adios2": {
4312+
"schema": 20210209,
4313+
"engine": {
4314+
"type": "bp4",
4315+
"usesteps": true
4316+
}
4317+
}
4318+
})";
4319+
4320+
bool weirdOrderWhenReading{};
4321+
4322+
{
4323+
Series series( filename, Access::CREATE, jsonConfig );
4324+
/*
4325+
* When using ADIOS2 steps, iterations are read not by logical order
4326+
* (iteration index), but by order of writing.
4327+
*/
4328+
weirdOrderWhenReading = series.backend() == "ADIOS2" &&
4329+
series.iterationEncoding() != IterationEncoding::fileBased;
4330+
if( variableBased )
4331+
{
4332+
if( series.backend() != "ADIOS2" )
4333+
{
4334+
return;
4335+
}
4336+
series.setIterationEncoding( IterationEncoding::variableBased );
4337+
}
4338+
for( auto currentIteration : iterations )
4339+
{
4340+
auto dataset =
4341+
series.writeIterations()[ currentIteration ]
4342+
.meshes[ "iterationOrder" ][ MeshRecordComponent::SCALAR ];
4343+
dataset.resetDataset( { determineDatatype< uint64_t >(), { 10 } } );
4344+
dataset.storeChunk( iterations, { 0 }, { 10 } );
4345+
// series.writeIterations()[ currentIteration ].close();
4346+
}
4347+
}
4348+
4349+
{
4350+
Series series( filename, Access::READ_ONLY );
4351+
size_t index = 0;
4352+
for( auto iteration : series.readIterations() )
4353+
{
4354+
if( weirdOrderWhenReading )
4355+
{
4356+
REQUIRE( iteration.iterationIndex == iterations[ index ] );
4357+
}
4358+
else
4359+
{
4360+
REQUIRE( iteration.iterationIndex == index );
4361+
}
4362+
++index;
4363+
}
4364+
REQUIRE( index == iterations.size() );
4365+
}
4366+
}
4367+
4368+
TEST_CASE( "chaotic_stream", "[serial]" )
4369+
{
4370+
for( auto const & t : testedFileExtensions() )
4371+
{
4372+
chaotic_stream( "../samples/chaotic_stream_filebased_%T." + t, false );
4373+
chaotic_stream( "../samples/chaotic_stream." + t, false );
4374+
chaotic_stream( "../samples/chaotic_stream_vbased." + t, true );
4375+
}
4376+
}

0 commit comments

Comments
 (0)