Skip to content

Commit

Permalink
Working on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timfelle committed Mar 11, 2024
1 parent eaa1c18 commit db33aea
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# ============================================================================ #
# Neko-TOP tests
# ============================================================================ #
# This CMakeLists.txt file is used to define the tests for the Neko-TOP
# library. The tests are defined using the pFUnit testing framework, which
# is a Fortran testing framework that is used to test the Neko-TOP library.
#
# ============================================================================ #
# External dependencies
# ============================================================================ #

# Setup of testing framework using pFUnit as the library
# and CMake as the build system.
#
Expand All @@ -7,53 +18,47 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(neko REQUIRED IMPORTED_TARGET neko)

# ============================================================================ #
# Setup the Neko tests
# Setup the Neko-TOP tests
# ============================================================================ #
# A couple of different types of tests can be setup and will be defined in this
# file. The tests are defined in the following way:
#
# 1. Sequential tests: These tests are run on a single processor and are used
# to test the basic functionality of the Neko-TOP library.
# 2. Parallel tests: These tests are run on multiple processors and are used
# to test the parallel functionality of the Neko-TOP library.
# 3. Performance tests: These tests are used to test the performance of the
# Neko-TOP library and are run on multiple processors.

# Find all .pf files in the test directory
set(NEKO_DIR ${CMAKE_SOURCE_DIR}/external/neko CACHE PATH
"Path to the Neko installation")
# ---------------------------------------------------------------------------- #
# Sequential tests

# Recursively find all .pf files in the test directory of Neko
file(GLOB_RECURSE neko_tests ${NEKO_DIR}/tests/*.pf)
# Recursively find all .pf files in the sequential directory.
file(GLOB_RECURSE sequential_tests ${CMAKE_CURRENT_SOURCE_DIR}/sequential/*.pf)

foreach(test ${neko_tests})
foreach(test ${sequential_tests})
get_filename_component(test_name ${test} NAME_WE)

# If the name contains "parallel" then we need to run it with more than one PE
set(mpi_pes 1)
if(${test_name} MATCHES "parallel")
set(mpi_pes 2)
endif()

# Add the neko tests
add_pfunit_ctest(neko_${test_name}
add_pfunit_ctest(neko-top_seq_${test_name}
TEST_SOURCES ${test}
LINK_LIBRARIES PkgConfig::neko MPI::MPI_Fortran
MAX_PES ${mpi_pes}
LINK_LIBRARIES PkgConfig::neko MPI::MPI_Fortran Neko-TOP
)
endforeach()

# ============================================================================ #
# Setup the Local Neko-top tests
# ============================================================================ #
# ---------------------------------------------------------------------------- #
# Parallel tests

# Recursively find all .pf files in the test directory of Neko
file(GLOB_RECURSE local_neko_tests ${CMAKE_CURRENT_SOURCE_DIR}/*.pf)
# Recursively find all .pf files in the parallel directory.
file(GLOB parallel_tests ${CMAKE_CURRENT_SOURCE_DIR}/parallel/*.pf)

foreach(test ${local_neko_tests})
foreach(test ${parallel_tests})
get_filename_component(test_name ${test} NAME_WE)

# If the name contains "parallel" then we need to run it with more than one PE
set(mpi_pes 1)
if(${test_name} MATCHES "parallel")
set(mpi_pes 2)
endif()

# Add the neko tests
add_pfunit_ctest(neko-top_${test_name}
add_pfunit_ctest(neko-top_par_${test_name}
TEST_SOURCES ${test}
LINK_LIBRARIES PkgConfig::neko MPI::MPI_Fortran Neko-TOP
MAX_PES ${mpi_pes}
MAX_PES 4
)
endforeach()

0 comments on commit db33aea

Please sign in to comment.