Skip to content

Commit

Permalink
Add ctest cases from existing example tests (#20)
Browse files Browse the repository at this point in the history
* rework github action for build and test and delete old one

* adapt workflow to be compatible with local execution using nektos/act

* switch back to explicit docker create/exec commands instead of 'container' option

The container option doesn't support QEMU emulation and thus selecting a architecture
different from the runners/host's one crashed the container with a 'exec format error'.

Unfortunately this breaks running the workflows locally using nektos/act. I still have
to figure out why exactly.

* fix whitespaces and newline at end of file

* replace hardcoded paths by variable ones in upload-artifact steps

* Clean up docker create command

* Consistently use bash -c in docker exec commands, and use single quotes instead of double quotes to prevent host side shell expansion

* Enable testing and add test cases from run_tests.sh

* Execute tests as non root since MPI requires this.

* fix newline at end of file

* set max. cores to two for debugging MPI in GitHub Action runners

* Add non-root user already in first stage, to make it available in the fans-ci image as well

* remove linux/arm64 from build and test workflow. Drop QEMU and make use of container: parameter

* add debug output to compare two ways of determining available cores/mpi slots

* use cmake_host_system_information instead as this actually gives the number of physical cores, which is the relevant number for MPI

* remove unnecessary ProcessorCount module include

* Update test names in CMake recipe

* Use correct path in test execution in the CMake recipe

* Use correct capital case

* Use correct relative path in test/CMakeLists.txt

Co-authored-by: Sanath Keshav <sanathkeshav.mysore@gmail.com>

---------

Co-authored-by: Ishaan Desai <ishaandesai@gmail.com>
Co-authored-by: Sanath Keshav <sanathkeshav.mysore@gmail.com>
  • Loading branch information
3 people authored Sep 20, 2024
1 parent 034d8cf commit 28782a0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,19 @@ install(
COMPONENT FANS_Development
)

# ##############################################################################
# TESTING
# ##############################################################################

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(FANS_ENABLE_TESTING_DEFAULT ON)
endif ()
option(FANS_ENABLE_TESTING "Enable testing" ${FANS_ENABLE_TESTING_DEFAULT})
if (FANS_ENABLE_TESTING)
enable_testing()
add_subdirectory(test)
endif ()

# ##############################################################################
# PACKAGING
# ##############################################################################
Expand Down
33 changes: 33 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
set(FANS_TEST_INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(FANS_TEST_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(FANS_EXECUTABLE $<TARGET_FILE:FANS_main>)

# determine MPI process count. The discretization of the test geometry allows for max. 8 processes.
set(FANS_N_MPI_PROCESSES_MAX 8)
cmake_host_system_information(RESULT FANS_CORES_AVAILABLE QUERY NUMBER_OF_PHYSICAL_CORES)
if (FANS_N_MPI_PROCESSES_MAX LESS FANS_CORES_AVAILABLE)
set(FANS_N_MPI_PROCESSES ${FANS_N_MPI_PROCESSES_MAX})
else()
set(FANS_N_MPI_PROCESSES ${FANS_CORES_AVAILABLE})
endif()
message(STATUS "Will use ${FANS_N_MPI_PROCESSES} processes for MPI test cases.")

set(FANS_TEST_CASES
J2Plasticity
LinearElastic
LinearThermal
PseudoPlastic
)

list(LENGTH FANS_TEST_CASES N_TESTS)
math(EXPR N_TESTS "${N_TESTS} - 1")

foreach(N RANGE ${N_TESTS})
list(GET FANS_TEST_CASES ${N} FANS_TEST_CASE)

add_test(
NAME ${FANS_TEST_CASE}
COMMAND mpiexec -n ${FANS_N_MPI_PROCESSES} ${FANS_EXECUTABLE} input_files/test_${FANS_TEST_CASE}.json ${FANS_TEST_OUTPUT_DIR}/test_${FANS_TEST_CASE}.h5
WORKING_DIRECTORY ${FANS_TEST_INPUT_DIR}
)
endforeach()

0 comments on commit 28782a0

Please sign in to comment.