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 bd452bd commit 7363390
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 44 deletions.
1 change: 1 addition & 0 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
1 change: 1 addition & 0 deletions .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
87 changes: 45 additions & 42 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,46 +45,49 @@ 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
- name: Run Unit Tests
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
ctest --preset ${{ matrix.build-setup.cmake-preset }} --output-junit junit.xml
# - 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@v14
# if: always()
# with:
# name: Unit Tests Reports (${{ matrix.build-setup.os }})
# reporter: jest-junit
# path: build/${{ matrix.build-setup.cmake-preset }}/junit.xml
# path-replace-backslashes: 'true' # Necessary for windows paths
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
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")
2 changes: 1 addition & 1 deletion test/UnitTests/Parallel/PLSerializer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TEST(PLSerializer, int)
nOut = serializer.GetInt();
serializer.Close();

ASSERT_EQ(nIn, nOut);
ASSERT_NE(nIn, nOut);
}

KHIOPS_TEST(PLSerializer, full, PLSerializer::Test);
Expand Down

0 comments on commit 7363390

Please sign in to comment.