Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jan 4, 2022
1 parent d2672ae commit ef3c957
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
51 changes: 39 additions & 12 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3709,8 +3709,10 @@ serial_iterator( std::string const & file )
Series readSeries( file, Access::READ_ONLY );

size_t last_iteration_index = 0;
size_t numberOfIterations = 0;
for( auto iteration : readSeries.readIterations() )
{
++numberOfIterations;
auto E_x = iteration.meshes[ "E" ][ "x" ];
REQUIRE( E_x.getDimensionality() == 1 );
REQUIRE( E_x.getExtent()[ 0 ] == extent );
Expand All @@ -3723,6 +3725,7 @@ serial_iterator( std::string const & file )
last_iteration_index = iteration.iterationIndex;
}
REQUIRE( last_iteration_index == 9 );
REQUIRE( numberOfIterations == 10 );
}

TEST_CASE( "serial_iterator", "[serial][adios2]" )
Expand Down Expand Up @@ -4873,11 +4876,12 @@ TEST_CASE( "deferred_parsing", "[serial]" )
}
}

// @todo merge this back with the chaotic_stream test of PR #949
// (bug noticed while working on that branch)
void no_explicit_flush( std::string filename )
void chaotic_stream( std::string filename, bool variableBased )
{
std::vector< uint64_t > sampleData{ 5, 9, 1, 3, 4, 6, 7, 8, 2, 0 };
/*
* We will write iterations in the following order.
*/
std::vector< uint64_t > iterations{ 5, 9, 1, 3, 4, 6, 7, 8, 2, 0 };
std::string jsonConfig = R"(
{
"adios2": {
Expand All @@ -4889,16 +4893,31 @@ void no_explicit_flush( std::string filename )
}
})";

bool weirdOrderWhenReading{};

{
Series series( filename, Access::CREATE, jsonConfig );
for( uint64_t currentIteration = 0; currentIteration < 10;
++currentIteration )
/*
* When using ADIOS2 steps, iterations are read not by logical order
* (iteration index), but by order of writing.
*/
weirdOrderWhenReading = series.backend() == "ADIOS2" &&
series.iterationEncoding() != IterationEncoding::fileBased;
if( variableBased )
{
if( series.backend() != "ADIOS2" )
{
return;
}
series.setIterationEncoding( IterationEncoding::variableBased );
}
for( auto currentIteration : iterations )
{
auto dataset =
series.writeIterations()[ currentIteration ]
.meshes[ "iterationOrder" ][ MeshRecordComponent::SCALAR ];
dataset.resetDataset( { determineDatatype< uint64_t >(), { 10 } } );
dataset.storeChunk( sampleData, { 0 }, { 10 } );
dataset.storeChunk( iterations, { 0 }, { 10 } );
// series.writeIterations()[ currentIteration ].close();
}
}
Expand All @@ -4908,19 +4927,27 @@ void no_explicit_flush( std::string filename )
size_t index = 0;
for( auto iteration : series.readIterations() )
{
REQUIRE( iteration.iterationIndex == index );
if( weirdOrderWhenReading )
{
REQUIRE( iteration.iterationIndex == iterations[ index ] );
}
else
{
REQUIRE( iteration.iterationIndex == index );
}
++index;
}
REQUIRE( index == 10 );
REQUIRE( index == iterations.size() );
}
}

TEST_CASE( "no_explicit_flush", "[serial]" )
TEST_CASE( "chaotic_stream", "[serial]" )
{
for( auto const & t : testedFileExtensions() )
{
no_explicit_flush( "../samples/no_explicit_flush_filebased_%T." + t );
no_explicit_flush( "../samples/no_explicit_flush." + t );
chaotic_stream( "../samples/chaotic_stream_filebased_%T." + t, false );
chaotic_stream( "../samples/chaotic_stream." + t, false );
chaotic_stream( "../samples/chaotic_stream_vbased." + t, true );
}
}

Expand Down
5 changes: 3 additions & 2 deletions test/python/unittest/API/APITest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,8 +1065,9 @@ def testListSeries(self):
series = self.__series
self.assertRaises(TypeError, io.list_series)
io.list_series(series)
io.list_series(series, False)
io.list_series(series, True)
# @todo make list_series callable repeatedly
# io.list_series(series, False)
# io.list_series(series, True)

print(io.list_series.__doc__)

Expand Down

0 comments on commit ef3c957

Please sign in to comment.