Skip to content

Commit

Permalink
testing: Update tests to work with non-parallel HDF5
Browse files Browse the repository at this point in the history
Previously the tests assumed that if ADIOS is built with MPI support
then HDF5 will also have it.  Revise logic to lift this assumption.
  • Loading branch information
bradking committed Feb 11, 2020
1 parent aae5cff commit c1eb780
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 81 deletions.
2 changes: 1 addition & 1 deletion testing/adios2/engine/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gtest_add_tests_helper(Common ${test_mpi} "" Engine. .File
EXTRA_ARGS "File" "1"
)

if(ADIOS2_HAVE_HDF5)
if(ADIOS2_HAVE_HDF5 AND HDF5_IS_PARALLEL)
gtest_add_tests_helper(Common ${test_mpi} "" Engine. .HDF5
EXTRA_ARGS "HDF5" "1"
)
Expand Down
17 changes: 12 additions & 5 deletions testing/adios2/engine/hdf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

gtest_add_tests_helper(WriteReadAsStream ${test_mpi} HDF5 Engine.HDF5. "")
gtest_add_tests_helper(StreamWriteReadHighLevelAPI ${test_mpi}
if(ADIOS2_HAVE_MPI AND HDF5_IS_PARALLEL)
set(hdf5_mpi TRUE)
add_definitions(-DTEST_HDF5_MPI)
else()
set(hdf5_mpi FALSE)
endif()

gtest_add_tests_helper(WriteReadAsStream ${hdf5_mpi} HDF5 Engine.HDF5. "")
gtest_add_tests_helper(StreamWriteReadHighLevelAPI ${hdf5_mpi}
HDF5 Engine.HDF5. ""
)
gtest_add_tests_helper(WriteReadAttributesADIOS2 ${test_mpi}
gtest_add_tests_helper(WriteReadAttributesADIOS2 ${hdf5_mpi}
HDF5 Engine.HDF5. ""
)
gtest_add_tests_helper(WriteMemorySelectionRead ${test_mpi}
gtest_add_tests_helper(WriteMemorySelectionRead ${hdf5_mpi}
HDF5 Engine.HDF5. ""
)

gtest_add_tests_helper(NativeHDF5WriteRead ${test_mpi} "" Engine.HDF5. "")
gtest_add_tests_helper(NativeHDF5WriteRead ${hdf5_mpi} "" Engine.HDF5. "")
if(HDF5_C_INCLUDE_DIRS)
target_include_directories(Test.Engine.HDF5.NativeHDF5WriteRead
PRIVATE ${HDF5_C_INCLUDE_DIRS}
Expand Down
24 changes: 12 additions & 12 deletions testing/adios2/engine/hdf5/TestHDF5StreamWriteReadHighLevelAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ TEST_F(StreamWriteReadHighLevelAPI_HDF5, ADIOS2H5writeRead1D8)
// Number of steps
const size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

// write test data using H5
{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::fstream oStream(fname, adios2::fstream::out, MPI_COMM_WORLD,
"HDF5");
#else
Expand Down Expand Up @@ -101,7 +101,7 @@ TEST_F(StreamWriteReadHighLevelAPI_HDF5, ADIOS2H5writeRead1D8)
adios2::fstream iStream;
EXPECT_FALSE(iStream);

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
iStream.open(fname, adios2::fstream::in, MPI_COMM_WORLD, "HDF5");
#else
iStream.open(fname, adios2::fstream::in, "HDF5");
Expand Down Expand Up @@ -272,14 +272,14 @@ TEST_F(StreamWriteReadHighLevelAPI_HDF5, ADIOS2H5writeRead2D2x4)
// Number of steps
const std::size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

// write test data using ADIOS2
{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::fstream oStream(fname, adios2::fstream::out, MPI_COMM_WORLD,
"HDF5");
#else
Expand Down Expand Up @@ -316,7 +316,7 @@ TEST_F(StreamWriteReadHighLevelAPI_HDF5, ADIOS2H5writeRead2D2x4)

// READ
{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::fstream iStream(fname, adios2::fstream::in, MPI_COMM_WORLD,
"HDF5");
#else
Expand Down Expand Up @@ -391,14 +391,14 @@ TEST_F(StreamWriteReadHighLevelAPI_HDF5, ADIOS2H5writeRead2D4x2)
// Number of steps
const std::size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

// write test data using ADIOS2
{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::fstream oStream(fname, adios2::fstream::out, MPI_COMM_WORLD,
"HDF5");
#else
Expand Down Expand Up @@ -437,7 +437,7 @@ TEST_F(StreamWriteReadHighLevelAPI_HDF5, ADIOS2H5writeRead2D4x2)
}

{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::fstream iStream(fname, adios2::fstream::in, MPI_COMM_WORLD,
"HDF5");
#else
Expand Down Expand Up @@ -501,7 +501,7 @@ TEST_F(StreamWriteReadHighLevelAPI_HDF5, DoubleOpenException)
const std::string fname("ADIOS2H5_hl_exception.h5");

{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::fstream oStream(fname, adios2::fstream::out, MPI_COMM_WORLD,
"HDF5");
EXPECT_THROW(oStream.open("second", adios2::fstream::out,
Expand All @@ -519,15 +519,15 @@ TEST_F(StreamWriteReadHighLevelAPI_HDF5, DoubleOpenException)

int main(int argc, char **argv)
{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Init(nullptr, nullptr);
#endif

int result;
::testing::InitGoogleTest(&argc, argv);
result = RUN_ALL_TESTS();

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Finalize();
#endif

Expand Down
22 changes: 11 additions & 11 deletions testing/adios2/engine/hdf5/TestHDF5WriteMemorySelectionRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ void HDF5Steps1D(const size_t ghostCells)
// Number of steps
const size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true);
Expand Down Expand Up @@ -331,7 +331,7 @@ void HDF5Steps1D(const size_t ghostCells)
}
h5Writer.Close();
}
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Barrier(MPI_COMM_WORLD);
#endif
// Reader
Expand Down Expand Up @@ -485,12 +485,12 @@ void HDF5Steps2D4x2(const size_t ghostCells)
// Number of steps
const size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true);
Expand Down Expand Up @@ -567,7 +567,7 @@ void HDF5Steps2D4x2(const size_t ghostCells)
}
h5Writer.Close();
}
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Barrier(MPI_COMM_WORLD);
#endif
// Reader
Expand Down Expand Up @@ -733,12 +733,12 @@ void HDF5Steps3D8x2x4(const size_t ghostCells)
// Number of steps
const size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true);
Expand Down Expand Up @@ -825,7 +825,7 @@ void HDF5Steps3D8x2x4(const size_t ghostCells)
}
h5Writer.Close();
}
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Barrier(MPI_COMM_WORLD);
#endif
// Reader
Expand Down Expand Up @@ -1042,7 +1042,7 @@ INSTANTIATE_TEST_CASE_P(ghostCells, HDF5WriteMemSelReadVector,

int main(int argc, char **argv)
{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Init(nullptr, nullptr);
#endif

Expand All @@ -1058,7 +1058,7 @@ int main(int argc, char **argv)

result = RUN_ALL_TESTS();

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Finalize();
#endif

Expand Down
24 changes: 12 additions & 12 deletions testing/adios2/engine/hdf5/TestHDF5WriteReadAsStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ TEST_F(HDF5WriteReadAsStreamTestADIOS2, ADIOS2HDF5WriteRead1D8)
// Number of steps
const size_t NSteps = 5;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

// Write test data using HDF5

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true);
Expand Down Expand Up @@ -384,14 +384,14 @@ TEST_F(HDF5WriteReadAsStreamTestADIOS2, ADIOS2HDF5WriteRead2D2x4)
// Number of steps
const std::size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

// Write test data using ADIOS2

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true);
Expand Down Expand Up @@ -632,14 +632,14 @@ TEST_F(HDF5WriteReadAsStreamTestADIOS2, ADIOS2HDF5WriteRead2D4x2)
// Number of steps
const std::size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

// Write test data using ADIOS2

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true);
Expand Down Expand Up @@ -884,14 +884,14 @@ TEST_F(HDF5WriteReadAsStreamTestADIOS2, ReaderWriterDefineVariable)
// Number of steps
const std::size_t NSteps = 3;

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif

// Write test data using ADIOS2

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true);
Expand Down Expand Up @@ -921,7 +921,7 @@ TEST_F(HDF5WriteReadAsStreamTestADIOS2, ReaderWriterDefineVariable)

h5Writer.Close();
}
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Barrier(MPI_COMM_WORLD);
#endif
{
Expand Down Expand Up @@ -954,7 +954,7 @@ TEST_F(HDF5WriteReadAsStreamTestADIOS2, ReaderWriterDefineVariable)
writer.Close();
reader.Close();
}
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Barrier(MPI_COMM_WORLD);
#endif
{
Expand All @@ -975,15 +975,15 @@ TEST_F(HDF5WriteReadAsStreamTestADIOS2, ReaderWriterDefineVariable)

int main(int argc, char **argv)
{
#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Init(nullptr, nullptr);
#endif

int result;
::testing::InitGoogleTest(&argc, argv);
result = RUN_ALL_TESTS();

#ifdef ADIOS2_HAVE_MPI
#ifdef TEST_HDF5_MPI
MPI_Finalize();
#endif

Expand Down
Loading

0 comments on commit c1eb780

Please sign in to comment.