Skip to content

Commit

Permalink
Unit Test for new fast failure
Browse files Browse the repository at this point in the history
  • Loading branch information
C0nsultant committed Aug 15, 2018
1 parent a89a6a4 commit 903f826
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/IO/ADIOS/ADIOS1IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace openPMD
{
#if openPMD_HAVE_ADIOS1
# if openPMD_USE_VERIFY
# define VERIFY(CONDITION, TEXT) { if(!(CONDITION)) throw std::runtime_error(std::string((TEXT))); }
# define VERIFY(CONDITION, TEXT) { if(!(CONDITION)) throw std::runtime_error((TEXT)); }
# else
# define VERIFY(CONDITION, TEXT) do{ (void)sizeof(CONDITION); } while( 0 )
# endif
Expand Down
46 changes: 22 additions & 24 deletions src/IO/ADIOS/ParallelADIOS1IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace openPMD
{
#if openPMD_HAVE_ADIOS1 && openPMD_HAVE_MPI
# if openPMD_USE_VERIFY
# define VERIFY(CONDITION, TEXT) { if(!(CONDITION)) throw std::runtime_error(std::string((TEXT))); }
# define VERIFY(CONDITION, TEXT) { if(!(CONDITION)) throw std::runtime_error((TEXT)); }
# else
# define VERIFY(CONDITION, TEXT) do{ (void)sizeof(CONDITION); } while( 0 )
# endif
Expand All @@ -52,32 +52,30 @@ ParallelADIOS1IOHandlerImpl::ParallelADIOS1IOHandlerImpl(AbstractIOHandler* hand

ParallelADIOS1IOHandlerImpl::~ParallelADIOS1IOHandlerImpl()
{
/* create all files where ADIOS file creation has been deferred,
* but execution of the deferred operation has never been triggered
* (happens when no Operation::WRITE_DATASET is performed) */
for( auto& f : m_existsOnDisk )
{
if( !f.second )
{
int64_t fd;
int status;
status = adios_open(&fd,
f.first->c_str(),
f.first->c_str(),
"w",
m_mpiComm);
if( status != err_no_error )
std::cerr << "Internal error: Failed to open_flush ADIOS file\n";

m_openWriteFileHandles[f.first] = fd;
}
}

for( auto& f : m_openReadFileHandles )
close(f.second);
m_openReadFileHandles.clear();

for( auto& f : m_openWriteFileHandles )
close(f.second);
if( this->m_handler->accessType != AccessType::READ_ONLY )
{
for( auto& f : m_openWriteFileHandles )
close(f.second);
m_openWriteFileHandles.clear();

for( auto& group : m_attributeWrites )
for( auto& att : group.second )
flush_attribute(group.first, att.first, att.second);

/* create all files, even if ADIOS file creation has been deferred,
* but execution of the deferred operation has never been triggered
* (happens when no Operation::WRITE_DATASET is performed) */
for( auto& f : m_filePaths )
if( m_openWriteFileHandles.find(f.second) == m_openWriteFileHandles.end() )
m_openWriteFileHandles[f.second] = open_write(f.first);

for( auto& f : m_openWriteFileHandles )
close(f.second);
}

int status;
MPI_Barrier(m_mpiComm);
Expand Down
2 changes: 1 addition & 1 deletion src/IO/HDF5/HDF5IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace openPMD
{
#if openPMD_HAVE_HDF5
# if openPMD_USE_VERIFY
# define VERIFY(CONDITION, TEXT) { if(!(CONDITION)) throw std::runtime_error(std::string((TEXT))); }
# define VERIFY(CONDITION, TEXT) { if(!(CONDITION)) throw std::runtime_error((TEXT)); }
# else
# define VERIFY(CONDITION, TEXT) do{ (void)sizeof(CONDITION); } while( 0 )
# endif
Expand Down
2 changes: 1 addition & 1 deletion src/IO/HDF5/ParallelHDF5IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace openPMD
{
#if openPMD_HAVE_HDF5 && openPMD_HAVE_MPI
# if openPMD_USE_VERIFY
# define VERIFY(CONDITION, TEXT) { if(!(CONDITION)) throw std::runtime_error(std::string((TEXT))); }
# define VERIFY(CONDITION, TEXT) { if(!(CONDITION)) throw std::runtime_error((TEXT)); }
# else
# define VERIFY(CONDITION, TEXT) do{ (void)sizeof(CONDITION); } while( 0 )
# endif
Expand Down
11 changes: 11 additions & 0 deletions test/CoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,3 +607,14 @@ TEST_CASE( "use_count_test", "[core]" )
REQUIRE(static_cast< Parameter< Operation::WRITE_DATASET >* >(pprc.m_chunks->front().parameter.get())->data.use_count() == 1);
#endif
}

TEST_CASE( "empty_record_test", "[core]" )
{
Series o = Series("./new_openpmd_output", AccessType::CREATE);

o.iterations[1].meshes["E"].setComment("No assumption about contained RecordComponents will be made");
REQUIRE_THROWS_WITH(o.flush(),
Catch::Equals("A Record can not be written without any contained RecordComponents: E"));
o.iterations[1].meshes["E"][RecordComponent::SCALAR].resetDataset(Dataset(Datatype::DOUBLE, {1}));
o.flush();
}
12 changes: 3 additions & 9 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,13 +953,6 @@ TEST_CASE( "hdf5_write_test", "[serial][hdf5]" )
std::generate(position_global.begin(), position_global.end(), [&pos]{ return pos++; });
std::vector< double > position_local = {0.};
e["position"]["x"].resetDataset(Dataset(determineDatatype<double>(), {4}));

for( uint64_t i = 0; i < 4; ++i )
{
position_local.at(0) = position_global[i];
e["position"]["x"].storeChunk({i}, {1}, shareRaw(position_local));
}

std::vector< uint64_t > positionOffset_global(4);
uint64_t posOff{0};
std::generate(positionOffset_global.begin(), positionOffset_global.end(), [&posOff]{ return posOff++; });
Expand All @@ -968,12 +961,13 @@ TEST_CASE( "hdf5_write_test", "[serial][hdf5]" )

for( uint64_t i = 0; i < 4; ++i )
{
position_local.at(0) = position_global[i];
e["position"]["x"].storeChunk({i}, {1}, shareRaw(position_local));
positionOffset_local[0] = positionOffset_global[i];
e["positionOffset"]["x"].storeChunk({i}, {1}, shareRaw(positionOffset_local));
o.flush();
}

o.flush();

//TODO close file, read back, verify
}

Expand Down

0 comments on commit 903f826

Please sign in to comment.