Skip to content

Commit

Permalink
Use ctest to run unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-at-orange committed Apr 9, 2024
1 parent b218c89 commit c239b9f
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 67 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/pack-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
mpi_implementation:
description: mpi implementation
type: choice
default: openmpi
options:
- mpich
- openmpi
Expand Down Expand Up @@ -40,10 +41,17 @@ jobs:
source /etc/os-release
echo "ID=$ID" >> "$GITHUB_ENV"
echo "VERSION_CODENAME=$VERSION_CODENAME" >> "$GITHUB_ENV"
if [ -z "${{ github.event.inputs.mpi_implementation }}" ] ;
then
echo "MPI_IMPLEMENTATION=openmpi" >> "$GITHUB_ENV"
else
echo "MPI_IMPLEMENTATION=${{ github.event.inputs.mpi_implementation }}" >> "$GITHUB_ENV"
fi
- name: Configure CMake
run: |
update-alternatives --set mpi /usr/bin/mpicc.${{ github.event.inputs.mpi_implementation }}
update-alternatives --set mpirun /usr/bin/mpirun.${{ github.event.inputs.mpi_implementation }}
update-alternatives --set mpi /usr/bin/mpicc.${{ env.MPI_IMPLEMENTATION }}
update-alternatives --set mpirun /usr/bin/mpirun.${{ env.MPI_IMPLEMENTATION }}
cmake --preset linux-gcc-release -DBUILD_JARS=ON
- name: Build Khiops binaries
run: |
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/pack-rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
mpi_implementation:
description: mpi implementation
type: choice
default: openmpi
options: [mpich, openmpi]
pull_request:
paths: ['**CMakeLists.txt', '**.cmake', .github/workflows/pack-rpm.yml]
Expand Down Expand Up @@ -37,11 +38,17 @@ jobs:
echo "ID=$ID" >> "$GITHUB_ENV"
VERSION_CODENAME=$(echo $PLATFORM_ID | cut -d":" -f2)
echo "VERSION_CODENAME=$VERSION_CODENAME" >> "$GITHUB_ENV"
if [ -z "${{ github.event.inputs.mpi_implementation }}" ] ;
then
echo "MPI_IMPLEMENTATION=openmpi" >> "$GITHUB_ENV"
else
echo "MPI_IMPLEMENTATION=${{ github.event.inputs.mpi_implementation }}" >> "$GITHUB_ENV"
fi
- name: Configure CMake
run: |
source /etc/profile.d/modules.sh
module unload mpi
module load mpi/${{ github.event.inputs.mpi_implementation }}-x86_64
module load mpi/${{ env.MPI_IMPLEMENTATION}}-x86_64
cmake --preset linux-gcc-release -DBUILD_JARS=ON
- name: Build Khiops binaries
run: |
Expand Down
46 changes: 3 additions & 43 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,46 +45,6 @@ jobs:
preset-name: ${{ matrix.build-setup.cmake-preset }}
targets: norm_test parallel_test parallel_mpi_test learning_test KNITest
override-flags: -DTESTING=ON
- name: Run Unit Tests for the Norm Module
run: |
build/${{ matrix.build-setup.cmake-preset }}/bin/norm_test \
--gtest_output="xml:reports/report-norm.xml"
- name: Run Unit Tests for the Parallel Module
if: always()
run: |
build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_test \
--gtest_output="xml:reports/report-parallel.xml"
- name: Run Unit Tests for the Parallel MPI Module in serial
if: always()
run: |
build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_mpi_test \
--gtest_output="xml:reports/report-parallel-mpi-serial.xml"
- name: Run Unit Tests for the Parallel MPI Module in parallel (Linux)
if: ${{ always() && runner.os == 'Linux' }}
run: |
mpirun --oversubscribe --use-hwthread-cpus -n 4 build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_mpi_test \
--gtest_output="xml:reports/report-parallel-mpi-parallel.xml"
- name: Run Unit Tests for the Parallel MPI Module in parallel (Windows and
macOS)
if: ${{ always() && runner.os != 'Linux' }}
run: |
mpiexec -n 4 build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_mpi_test \
--gtest_output="xml:reports/report-parallel-mpi-parallel.xml"
- name: Run Unit Tests for the Learning Module
if: always()
run: |
build/${{ matrix.build-setup.cmake-preset }}/bin/learning_test \
--gtest_output="xml:reports/report-learning.xml"
- name: Run Unit Tests for the KNI Module
if: always()
run: |
build/${{ matrix.build-setup.cmake-preset }}/bin/KNITest \
--gtest_output="xml:reports/report-kni.xml"
- name: Create Unit Test Reports Dashboards
uses: phoenix-actions/test-reporting@v12
if: always()
with:
name: Unit Tests Reports (${{ matrix.build-setup.os }})
reporter: jest-junit
path: reports/report-*.xml
path-replace-backslashes: 'true' # Necessary for windows paths
- name: Run Unit Tests
run: |-
ctest --preset ${{ matrix.build-setup.cmake-preset }}
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"generator": "Ninja",
"cacheVariables": {
"MPI": "ON",
"TESTING": "OFF",
"TESTING": "ON",
"BUILD_JARS": "OFF",
"BUILD_LEX_YACC": "OFF",
"C11": "ON"
Expand Down
21 changes: 16 additions & 5 deletions packaging/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,35 @@ configure_file(${PROJECT_SOURCE_DIR}/packaging/common/KNI/template-README.md ${T

# ######################################## Khiops and Khiops Coclustering installation

# replace MPIEXEC MPIEXEC_NUMPROC_FLAG and MPI_IMPL
configure_file(${PROJECT_SOURCE_DIR}/packaging/linux/common/khiops-env.in ${TMP_DIR}/khiops-env @ONLY
NEWLINE_STYLE UNIX)

if(NOT IS_FEDORA_LIKE)
install(TARGETS MODL MODL_Coclustering RUNTIME DESTINATION usr/bin COMPONENT KHIOPS_CORE)

# We install the binary with mpi suffix and create a symlink without the suffix
get_target_property(MODL_NAME MODL OUTPUT_NAME)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/bin/${MODL_NAME} ${CMAKE_BINARY_DIR}/MODL)
install(
FILES ${CMAKE_BINARY_DIR}/MODL
DESTINATION usr/bin
COMPONENT KHIOPS_CORE)
else()

# On fedora binaries built with mpi must follow these rules :
#
# - the binaries MUST be suffixed with $MPI_SUFFIX
# - MPI implementation specific files MUST be installed in the directories used by the used MPI compiler e.g. $MPI_BIN
# - MPI implementation specific files MUST be installed in the directories used by the MPI compiler e.g. $MPI_BIN
#
# see https://docs.fedoraproject.org/en-US/packaging-guidelines/MPI/
#
install(TARGETS MODL RUNTIME DESTINATION ./${MPI_BIN}/khiops COMPONENT KHIOPS_CORE)
install(TARGETS MODL_Coclustering RUNTIME DESTINATION /usr/bin COMPONENT KHIOPS_CORE)

# We install the binary under $MPI_BIN and create a symlink to it
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${MPI_BIN}/khiops/MODL${MPI_SUFFIX}
${CMAKE_BINARY_DIR}/MODL)
get_target_property(MODL_NAME MODL OUTPUT_NAME)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${MPI_BIN}/khiops/${MODL_NAME} ${CMAKE_BINARY_DIR}/MODL)
install(
FILES ${CMAKE_BINARY_DIR}/MODL
DESTINATION usr/bin
Expand All @@ -85,8 +97,7 @@ endif()

install(
PROGRAMS ${PROJECT_SOURCE_DIR}/packaging/linux/common/khiops
${PROJECT_SOURCE_DIR}/packaging/linux/common/khiops_coclustering
${PROJECT_SOURCE_DIR}/packaging/linux/common/khiops-env
${PROJECT_SOURCE_DIR}/packaging/linux/common/khiops_coclustering ${TMP_DIR}/khiops-env
DESTINATION usr/bin
COMPONENT KHIOPS_CORE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,8 @@ if ! command -v mpiexec &> /dev/null
then
if source /etc/profile.d/modules.sh &> /dev/null
then
# find the good module
# mpich_module="$(module avail |& sed -E -e 's/[[:blank:]]+/\n/g' | grep mpich-[0-9] | grep $(arch) | sort | tail -n 1)"
# if [ -z "$mpich_module" ] ; then
# mpich_module=$(module avail |& sed -E -e 's/[[:blank:]]+/\n/g' | grep mpich-$(arch))
# fi

# and load it
module unload mpi
module load mpi/openmpi-x86_64
module load mpi/@MPI_IMPL@-x86_64
fi
fi

Expand All @@ -79,12 +72,14 @@ if [[ -z $KHIOPS_PROC_NUMBER ]]; then
KHIOPS_PROC_NUMBER=$(( $(lscpu -b -p=Core,Socket | grep -v '^#' | sort -u | wc -l) + 1 ))
fi

if command -v mpiexec &> /dev/null
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG}

if command -v @MPIEXEC@ &> /dev/null
then
MPIEXEC_PATH=$(command -v mpiexec)
KHIOPS_MPI_COMMAND="${MPIEXEC_PATH} --allow-run-as-root --quiet --oversubscribe -n $KHIOPS_PROC_NUMBER"
MPIEXEC_PATH=$(command -v @MPIEXEC@)
KHIOPS_MPI_COMMAND="${MPIEXEC_PATH} -bind-to hwthread -map-by core @MPIEXEC_NUMPROC_FLAG@ $KHIOPS_PROC_NUMBER"
else
echo "We didn't find mpiexec in the regular path. Parallel computation is unavailable: Khiops is launched in serial"
echo "We didn't find @MPIEXEC@ in the regular path. Parallel computation is unavailable: Khiops is launched in serial"
KHIOPS_MPI_COMMAND=""
fi

Expand Down
8 changes: 5 additions & 3 deletions test/LearningTestTool/py/_kht_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ def check_family(family):

# Liste des familles, de la plus simple a la plus complete
BASIC = "basic" # Famille elementaire, tres rapide a tester
FULL = "full" # Famille correspondant a tous les tests de non regression (environ une heure a tester)
# Famille correspondant a tous les tests de non regression (environ une heure a tester)
FULL = "full"
FULL_NO_KNI = "full-no-kni" # Idem, sans KNI
COMPLETE = "complete" # Famille complete, tres lourde a tester (environ une journee)
# Famille complete, tres lourde a tester (environ une journee)
COMPLETE = "complete"
ALL = "all" # Tous les repertoire de suite exhaustivement: ne pas utiliser pour les test, mais pour leur gestion
TEST_FAMILIES = [BASIC, FULL, FULL_NO_KNI, COMPLETE, ALL]
assert len(set(TEST_FAMILIES)) == len(TEST_FAMILIES), (
Expand All @@ -36,7 +38,7 @@ def check_family(family):
assert DEFAULT_TEST_FAMILY in TEST_FAMILIES

# Cas de la version V11, qui inclus des suites de test additionnelles
KHIOPS_V11 = True
KHIOPS_V11 = False

# Ensuite des suites de test par famille et par outils
# Pour le cas particlier le la famille ALL, les suite ne sont pas specifiee:
Expand Down
9 changes: 9 additions & 0 deletions test/UnitTests/Parallel-mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ target_include_directories(parallel_mpi_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_options(parallel_mpi_test PUBLIC ${GTEST_CFLAGS})
include(GoogleTest)
gtest_discover_tests(parallel_mpi_test)

# Add the same test in CTest framework. It allows to run the test directly with the right mpi command. The command
# "ctest --preset linux-gcc-release -L mpi" will run (depending on the mpi implementation and the core number): mpiexec
# -n 8 build/linux-gcc-release/parallel_mpi_test
add_test(NAME ctest_parallel_mpi_test COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
${MPIEXEC_PREFLAGS} $<TARGET_FILE:parallel_mpi_test> ${MPIEXEC_POSTFLAGS})

# Add "mpi" label to the test
set_tests_properties(ctest_parallel_mpi_test PROPERTIES LABELS "mpi")

0 comments on commit c239b9f

Please sign in to comment.