Skip to content

Commit

Permalink
Merge pull request #1767 from chuckatkins/more-test-refactoring
Browse files Browse the repository at this point in the history
Added more test macro wrapping
  • Loading branch information
Chuck Atkins committed Sep 21, 2019
2 parents a112f6b + 6e3efb9 commit 2d2f067
Show file tree
Hide file tree
Showing 44 changed files with 379 additions and 551 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ add_subdirectory(source)
#------------------------------------------------------------------------------#
add_subdirectory(bindings)

#------------------------------------------------------------------------------#
# Examples
#------------------------------------------------------------------------------#
option(ADIOS2_BUILD_EXAMPLES "Build examples" ON)
option(ADIOS2_BUILD_EXAMPLES_EXPERIMENTAL "Build experimental examples" OFF)
if(ADIOS2_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

#------------------------------------------------------------------------------#
# Testing
#------------------------------------------------------------------------------#
Expand All @@ -219,15 +228,6 @@ if(BUILD_TESTING)
add_subdirectory(testing)
endif()

#------------------------------------------------------------------------------#
# Examples
#------------------------------------------------------------------------------#
option(ADIOS2_BUILD_EXAMPLES "Build examples" ON)
option(ADIOS2_BUILD_EXAMPLES_EXPERIMENTAL "Build experimental examples" OFF)
if(ADIOS2_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

#------------------------------------------------------------------------------#
# Generating package configs
#------------------------------------------------------------------------------#
Expand Down Expand Up @@ -280,6 +280,7 @@ endif()
message(" Library Type: ${msg_lib_type}")
message(" Build Type: ${CMAKE_BUILD_TYPE}")
message(" Testing: ${BUILD_TESTING}")
message(" Examples: ${ADIOS2_BUILD_EXAMPLES}")
message(" Build Options:")

foreach(opt IN LISTS ADIOS2_CONFIG_OPTS)
Expand All @@ -295,4 +296,3 @@ message(" RDMA Transport for Staging: Available")
else()
message(" RDMA Transport for Staging: Unconfigured")
endif()
message("")
6 changes: 5 additions & 1 deletion cmake/ADIOSFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ function(SetupTestPipeline basename pipeline do_setup)
-DDIR_NAME=${CMAKE_CURRENT_BINARY_DIR}/${basename}
-P ${PROJECT_SOURCE_DIR}/cmake/EmptyDir.cmake
)
list(INSERT pipeline 0 "Setup")
if(pipeline)
list(INSERT pipeline 0 "Setup")
else()
set(pipeline "Setup;")
endif()
endif()
unset(prev_suffix)
foreach(curr_step IN LISTS pipeline)
Expand Down
4 changes: 1 addition & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ add_subdirectory(query)
add_subdirectory(useCases)

if(ADIOS2_HAVE_MPI)
#if(MPIEXEC_MAX_NUMPROCS GREATER 3)
add_subdirectory(heatTransfer)
#endif()
add_subdirectory(heatTransfer)
endif()

if(ADIOS2_BUILD_EXAMPLES_EXPERIMENTAL)
Expand Down
41 changes: 35 additions & 6 deletions testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,52 @@ else()
endif()

include(GoogleTest)
function(gtest_add_tests_helper testname mpi pfx sfx)
set(tgt Test.${pfx}${testname})
# gtest_add_tests_helper:
# Create a wrapper around gtest_add_tests that uses common patterns for test
# names, execurtable names, mpi usage, etc.
#
# Arguments:
# testname - The basename of the test file
# mpi - TRUE - build with MPI, execute with mpiexec
# FALSE - no mpi
# NOEXEC - build with MPI but don't execute with MPI
# src_pfx - Source filename prefix, Test${src_pfs}${testname}.cpp
# tst_pfx - Test name prefix to be added to CTest
# tst_sfx - Test name suffix to be added to CTest
# all additional arguments are passed directly to gtest_add_tests
#
# Example:
# You have a gtest file, TestFooThings.cpp that containst Test1 and Test2
# gtest functions that can be called with different sets of arguments.
#
# gtest_add_tests_helper(Things TRUE Foo Foo. .Bar EXTRA_ARGS "Bar")
# gtest_add_tests_helper(Things TRUE Foo Foo. .Baz EXTRA_ARGS "Baz")
#
# will create the executable Test.Foo.Things and add the tests
# Foo.Things.Test1.Bar
# Foo.Things.Test2.Bar
# Foo.Things.Test1.Baz
# Foo.Things.Test2.Baz
#
function(gtest_add_tests_helper testname mpi src_pfx tst_pfx tst_sfx)
set(tgt Test.${tst_pfx}${testname})
if(NOT TARGET ${tgt})
add_executable(${tgt} Test${testname}.cpp)
add_executable(${tgt} Test${src_pfx}${testname}.cpp)
target_link_libraries(${tgt} adios2 gtest)
if(mpi)
target_link_libraries(${tgt} MPI::MPI_C)
endif()
endif()
if(mpi)
gtest_add_tests(TARGET ${tgt} TEST_PREFIX "${pfx}" TEST_SUFFIX "${sfx}"
if(mpi AND NOT mpi STREQUAL "NOEXEC")
gtest_add_tests(TARGET ${tgt}
TEST_PREFIX "${tst_pfx}" TEST_SUFFIX "${tst_sfx}"
EXEC_WRAPPER ${MPIEXEC_COMMAND} TEST_LIST added_tests
${ARGN}
)
set_tests_properties(${added_tests} PROPERTIES PROCESSORS ${NUM_TEST_PROCS})
else()
gtest_add_tests(TARGET ${tgt} TEST_PREFIX "${pfx}" TEST_SUFFIX "${sfx}"
gtest_add_tests(TARGET ${tgt}
TEST_PREFIX "${tst_pfx}" TEST_SUFFIX "${tst_sfx}"
${ARGN}
)
endif()
Expand Down
8 changes: 4 additions & 4 deletions testing/adios2/bindings/C/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ else()
set(mpi FALSE)
endif()

gtest_add_tests_helper(BPWriteTypes ${mpi} "Bindings.C." "")
gtest_add_tests_helper(BPWriteReadMultiblock ${mpi} "Bindings.C." "")
gtest_add_tests_helper(NullWriteRead ${mpi} "Bindings.C." "")
gtest_add_tests_helper(WriteTypes ${mpi} BP Bindings.C. "")
gtest_add_tests_helper(WriteReadMultiblock ${mpi} BP Bindings.C. "")
gtest_add_tests_helper(NullWriteRead ${mpi} "" Bindings.C. "")
if(mpi)
gtest_add_tests_helper(BPWriteAggregateReadLocal TRUE "Bindings.C." "")
gtest_add_tests_helper(WriteAggregateReadLocal TRUE BP Bindings.C. "")
endif()
52 changes: 26 additions & 26 deletions testing/adios2/engine/bp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,52 @@ file(MAKE_DIRECTORY ${BP3_DIR})
file(MAKE_DIRECTORY ${BP4_DIR})

macro(bp3_bp4_gtest_add_tests_helper testname)
gtest_add_tests_helper(${testname} ${test_mpi} Engine.BP. .BP3
gtest_add_tests_helper(${testname} ${test_mpi} BP Engine.BP. .BP3
WORKING_DIRECTORY ${BP3_DIR} EXTRA_ARGS "BP3"
)
gtest_add_tests_helper(${testname} ${test_mpi} Engine.BP. .BP4
gtest_add_tests_helper(${testname} ${test_mpi} BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
)
endmacro()

add_subdirectory(operations)

bp3_bp4_gtest_add_tests_helper(BPWriteReadADIOS2)
bp3_bp4_gtest_add_tests_helper(BPWriteReadADIOS2fstream)
bp3_bp4_gtest_add_tests_helper(BPWriteReadADIOS2stdio)
bp3_bp4_gtest_add_tests_helper(BPWriteReadAsStreamADIOS2)
bp3_bp4_gtest_add_tests_helper(BPWriteReadAsStreamADIOS2_Threads)
bp3_bp4_gtest_add_tests_helper(BPWriteReadAttributesADIOS2)
bp3_bp4_gtest_add_tests_helper(StreamWriteReadHighLevelAPI)
bp3_bp4_gtest_add_tests_helper(BPWriteFlushRead)
bp3_bp4_gtest_add_tests_helper(BPWriteMultiblockRead)
bp3_bp4_gtest_add_tests_helper(BPWriteReadMultiblock)
bp3_bp4_gtest_add_tests_helper(BPWriteReadVector)
bp3_bp4_gtest_add_tests_helper(BPWriteReadAttributesMultirank)
bp3_bp4_gtest_add_tests_helper(BPLargeMetadata)
bp3_bp4_gtest_add_tests_helper(BPWriteMemorySelectionRead)
bp3_bp4_gtest_add_tests_helper(BPWriteReadLocalVariables)
bp3_bp4_gtest_add_tests_helper(BPWriteReadLocalVariablesSel)
bp3_bp4_gtest_add_tests_helper(BPWriteReadLocalVariablesSelHighLevel)
bp3_bp4_gtest_add_tests_helper(BPChangingShape)
bp3_bp4_gtest_add_tests_helper(BPWriteReadBlockInfo)
bp3_bp4_gtest_add_tests_helper(WriteReadADIOS2)
bp3_bp4_gtest_add_tests_helper(WriteReadADIOS2fstream)
bp3_bp4_gtest_add_tests_helper(WriteReadADIOS2stdio)
bp3_bp4_gtest_add_tests_helper(WriteReadAsStreamADIOS2)
bp3_bp4_gtest_add_tests_helper(WriteReadAsStreamADIOS2_Threads)
bp3_bp4_gtest_add_tests_helper(WriteReadAttributesADIOS2)
bp3_bp4_gtest_add_tests_helper(FStreamWriteReadHighLevelAPI)
bp3_bp4_gtest_add_tests_helper(WriteFlushRead)
bp3_bp4_gtest_add_tests_helper(WriteMultiblockRead)
bp3_bp4_gtest_add_tests_helper(WriteReadMultiblock)
bp3_bp4_gtest_add_tests_helper(WriteReadVector)
bp3_bp4_gtest_add_tests_helper(WriteReadAttributesMultirank)
bp3_bp4_gtest_add_tests_helper(LargeMetadata)
bp3_bp4_gtest_add_tests_helper(WriteMemorySelectionRead)
bp3_bp4_gtest_add_tests_helper(WriteReadLocalVariables)
bp3_bp4_gtest_add_tests_helper(WriteReadLocalVariablesSel)
bp3_bp4_gtest_add_tests_helper(WriteReadLocalVariablesSelHighLevel)
bp3_bp4_gtest_add_tests_helper(ChangingShape)
bp3_bp4_gtest_add_tests_helper(WriteReadBlockInfo)

if(ADIOS2_HAVE_MPI)
bp3_bp4_gtest_add_tests_helper(BPWriteAggregateRead)
bp3_bp4_gtest_add_tests_helper(WriteAggregateRead)
endif()

# BP3 only for now
gtest_add_tests_helper(BPWriteReadVariableSpan ${test_mpi} Engine.BP. .BP3
gtest_add_tests_helper(WriteReadVariableSpan ${test_mpi} BP Engine.BP. .BP3
WORKING_DIRECTORY ${BP3_DIR} EXTRA_ARGS "BP3"
)
gtest_add_tests_helper(BPWriteNull ${test_mpi} Engine.BP. .BP3
gtest_add_tests_helper(WriteNull ${test_mpi} BP Engine.BP. .BP3
WORKING_DIRECTORY ${BP3_DIR} EXTRA_ARGS "BP3"
)

# BP4 only for now
gtest_add_tests_helper(BPWriteAppendReadADIOS2 ${test_mpi} Engine.BP. .BP4
gtest_add_tests_helper(WriteAppendReadADIOS2 ${test_mpi} BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
)
gtest_add_tests_helper(BPTimeAggregationADIOS2 ${test_mpi} Engine.BP. .BP4
gtest_add_tests_helper(TimeAggregationADIOS2 ${test_mpi} BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
)
18 changes: 9 additions & 9 deletions testing/adios2/engine/bp/operations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ file(MAKE_DIRECTORY ${BP3_DIR})
file(MAKE_DIRECTORY ${BP4_DIR})

if(ADIOS2_HAVE_SZ)
bp3_bp4_gtest_add_tests_helper(BPWriteReadSZ)
bp3_bp4_gtest_add_tests_helper(WriteReadSZ)
endif()


if(ADIOS2_HAVE_ZFP)
bp3_bp4_gtest_add_tests_helper(BPWriteReadZfp)
bp3_bp4_gtest_add_tests_helper(BPWriteReadZfpHighLevelAPI)
bp3_bp4_gtest_add_tests_helper(BPWriteReadZfpConfig)
target_compile_definitions(Test.Engine.BP.BPWriteReadZfpConfig PRIVATE
bp3_bp4_gtest_add_tests_helper(WriteReadZfp)
bp3_bp4_gtest_add_tests_helper(WriteReadZfpHighLevelAPI)
bp3_bp4_gtest_add_tests_helper(WriteReadZfpConfig)
target_compile_definitions(Test.Engine.BP.WriteReadZfpConfig PRIVATE
"XML_CONFIG_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
)
endif()

if(ADIOS2_HAVE_MGARD)
bp3_bp4_gtest_add_tests_helper(BPWriteReadMGARD)
bp3_bp4_gtest_add_tests_helper(WriteReadMGARD)
endif()

if(ADIOS2_HAVE_BZip2)
bp3_bp4_gtest_add_tests_helper(BPWriteReadBZIP2)
bp3_bp4_gtest_add_tests_helper(WriteReadBZIP2)
endif()

if(ADIOS2_HAVE_PNG)
bp3_bp4_gtest_add_tests_helper(BPWriteReadPNG)
bp3_bp4_gtest_add_tests_helper(WriteReadPNG)
endif()

if(ADIOS2_HAVE_Blosc)
bp3_bp4_gtest_add_tests_helper(BPWriteReadBlosc)
bp3_bp4_gtest_add_tests_helper(WriteReadBlosc)
endif()
18 changes: 8 additions & 10 deletions testing/adios2/engine/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,33 @@ endif()
# 2nd arg: 1 for serialized execution, 0 for concurrent execution of Writer/Reader
# 3rd arg: engine parameters

gtest_add_tests_helper(Common ${test_mpi} "Engine." ".File"
gtest_add_tests_helper(Common ${test_mpi} "" Engine. .File
EXTRA_ARGS "File" "1"
)

if(ADIOS2_HAVE_HDF5)
gtest_add_tests_helper(Common ${test_mpi} "Engine." ".HDF5"
gtest_add_tests_helper(Common ${test_mpi} "" Engine. .HDF5
EXTRA_ARGS "HDF5" "1"
)
endif()

if(ADIOS2_HAVE_SST)
gtest_add_tests_helper(Common ${test_mpi} "Engine." ".SST.FFS"
gtest_add_tests_helper(Common ${test_mpi} "" Engine. .SST.FFS
EXTRA_ARGS "SST" "0" "MarshalMethod:FFS"
)
gtest_add_tests_helper(Common ${test_mpi} "Engine." ".SST.BP"
gtest_add_tests_helper(Common ${test_mpi} "" Engine. .SST.BP
EXTRA_ARGS "SST" "0" "MarshalMethod:BP"
)
endif()

if(ADIOS2_HAVE_MPI)
gtest_add_tests_helper(Common TRUE "Engine." ".InSituMPI"
gtest_add_tests_helper(Common TRUE "" Engine. .InSituMPI
EXTRA_ARGS "InSituMPI" "0"
)
endif()

#if(ADIOS2_HAVE_DataMan)
#gtest_add_tests(TARGET TestEngineCommon ${extra_test_args}
# EXTRA_ARGS "DataMan" "0"
# TEST_SUFFIX _DataMan)
# gtest_add_tests_helper(Common TRUE "" Engine. .DataMan
# EXTRA_ARGS "DataMan" "0"
# )
#endif()


43 changes: 8 additions & 35 deletions testing/adios2/engine/dataman/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,12 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_ZeroMQ)

add_executable(TestDataManP2P2DMemSelect TestDataManP2P2DMemSelect.cpp)
target_link_libraries(TestDataManP2P2DMemSelect adios2 gtest MPI::MPI_C)
gtest_add_tests(TARGET TestDataManP2P2DMemSelect)

add_executable(TestDataManP2P3DMemSelect TestDataManP2P3DMemSelect.cpp)
target_link_libraries(TestDataManP2P3DMemSelect adios2 gtest MPI::MPI_C)
gtest_add_tests(TARGET TestDataManP2P3DMemSelect)

add_executable(TestDataManP2P1D TestDataManP2P1D.cpp)
target_link_libraries(TestDataManP2P1D adios2 gtest MPI::MPI_C)
gtest_add_tests(TARGET TestDataManP2P1D)

add_executable(TestDataManP2PZfp2D TestDataManP2PZfp2D.cpp)
target_link_libraries(TestDataManP2PZfp2D adios2 gtest MPI::MPI_C)
gtest_add_tests(TARGET TestDataManP2PZfp2D)

add_executable(TestDataManP2PSz2D TestDataManP2PSz2D.cpp)
target_link_libraries(TestDataManP2PSz2D adios2 gtest MPI::MPI_C)
gtest_add_tests(TARGET TestDataManP2PSz2D)

add_executable(TestDataManSubscribe1D TestDataManSubscribe1D.cpp)
target_link_libraries(TestDataManSubscribe1D adios2 gtest MPI::MPI_C)
gtest_add_tests(TARGET TestDataManSubscribe1D)

add_executable(TestDataManMpiBase TestDataManMpiBase.cpp)
target_link_libraries(TestDataManMpiBase adios2 gtest MPI::MPI_C)
add_test(
NAME DataManEngineTest.MpiBase
COMMAND ${CMAKE_COMMAND}
-DCMD1=TestDataManMpiBase.dataman
-DCMD2=$<TARGET_FILE:TestDataManMpiBase>
-P ${CMAKE_CURRENT_SOURCE_DIR}/RunTest.cmake)

if(ADIOS2_HAVE_MPI)
gtest_add_tests_helper(P2P2DMemSelect NOEXEC DataMan Engine.DataMan. "")
gtest_add_tests_helper(P2P3DMemSelect NOEXEC DataMan Engine.DataMan. "")
gtest_add_tests_helper(P2P1D NOEXEC DataMan Engine.DataMan. "")
gtest_add_tests_helper(P2PZfp2D NOEXEC DataMan Engine.DataMan. "")
gtest_add_tests_helper(P2PSz2D NOEXEC DataMan Engine.DataMan. "")
gtest_add_tests_helper(Subscribe1D NOEXEC DataMan Engine.DataMan. "")
gtest_add_tests_helper(MpiBase TRUE DataMan Engine.DataMan. "")
endif()
Loading

0 comments on commit 2d2f067

Please sign in to comment.