Skip to content

Commit

Permalink
Add gdb to tests run via CI in order to obtain more information upon …
Browse files Browse the repository at this point in the history
…segfault

Also disabled parallelism in cmake.yml so that the build log is more readable.
The extra time it takes is not a concern.
  • Loading branch information
nbelakovski committed Dec 14, 2023
1 parent 953cfed commit b657be1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 15 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ jobs:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS
submodules: recursive

- name: Miscellaneous setup
run: bash .github/scripts/misc_setup

- name: Install Ninja / Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt update && sudo apt install ninja-build
- name: Install Ninja / MacOS
if: ${{ matrix.os == 'macos-latest' }}
run: brew install ninja
- name: Install Ninja / Windows
if: ${{ matrix.os == 'windows-latest' }}
run: choco install ninja
- uses: fortran-lang/setup-fortran@main
id: setup-fortran
with:
Expand All @@ -103,16 +109,18 @@ jobs:
run: |
cmake --version
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. -LAH -DCMAKE_C_FLAGS="${{ matrix.toolchain.cflags }}" -DCMAKE_Fortran_FLAGS="${{ matrix.toolchain.fflags }}" .
cmake --build . --target install --parallel 4
cmake --build . --target tests --parallel 4
ctest --output-on-failure -V -j4 -E stress
cmake --build . --target install
cmake --build . --target tests
ctest --output-on-failure -V -E stress
shell: bash
env:
FC: ${{ steps.setup-fortran.outputs.fc }}

- name: Stress test
if: ${{ github.event_name == 'schedule' || github.event.inputs.stress-test == 'true' }}
run: |
ctest --output-on-failure -V -j4 -R stress
ctest --output-on-failure -V -R stress
shell: bash


cmake-other:
Expand Down Expand Up @@ -142,6 +150,9 @@ jobs:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS
submodules: recursive

- name: Miscellaneous setup
run: bash .github/scripts/misc_setup

- name: Install AOCC
if: ${{ matrix.toolchain.compiler == 'aflang' }}
run: bash .github/scripts/install_aocc
Expand All @@ -157,17 +168,19 @@ jobs:
- name: Build
run: |
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. -LAH -DCMAKE_C_FLAGS="${{ matrix.toolchain.cflags }}" -DCMAKE_Fortran_FLAGS="${{ matrix.toolchain.fflags }}" .
cmake --build . --target install --parallel 4
cmake --build . --target tests --parallel 4
cmake --build . --target install
cmake --build . --target tests
# cobyla test does not pass on AOCC: https://github.com/libprima/prima/issues/41
ctest --output-on-failure -V -j4 -E "stress|cobyla"
ctest --output-on-failure -V -E "stress|cobyla"
shell: bash
env:
FC: ${{ matrix.toolchain.compiler }}

- name: Stress test
if: ${{ github.event_name == 'schedule' || github.event.inputs.stress-test == 'true' }}
run: |
ctest --output-on-failure -V -j4 -R stress -E cobyla
ctest --output-on-failure -V -R stress -E cobyla
shell: bash


# The following job check whether the tests were successful or cancelled due to timeout.
Expand Down
10 changes: 9 additions & 1 deletion c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ macro (prima_add_c_test name)
if (WIN32)
set_target_properties(example_${name}_c_exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
endif()
add_test (NAME example_${name}_c COMMAND example_${name}_c_exe)
if (APPLE)
add_test (NAME example_${name}_c COMMAND example_${name}_c_exe)
elseif(UNIX)
# We prefer to run with gdb so that CI will give us some information in the event of a segfault or other crash.
# GitHub actions will not run gdb on Apple due to its security policy.
add_test (NAME example_${name}_c COMMAND gdb -batch -ex run -ex where -ex quit example_${name}_c_exe)
elseif(WIN32)
add_test (NAME example_${name}_c COMMAND gdb -batch -ex run -ex where -ex "if \$_exitcode != 0 quit \$_exitcode" -ex quit ../bin/example_${name}_c_exe.exe)
endif()
add_dependencies(examples example_${name}_c_exe)
endmacro ()

Expand Down
27 changes: 22 additions & 5 deletions c/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ macro (prima_add_c_test_multi name)
endif()
target_link_libraries(${name}_c_exe PRIVATE primac)
add_dependencies(tests ${name}_c_exe)
add_test(NAME bobyqa_${name}_c COMMAND ${name}_c_exe bobyqa)
add_test(NAME cobyla_${name}_c COMMAND ${name}_c_exe cobyla)
add_test(NAME lincoa_${name}_c COMMAND ${name}_c_exe lincoa)
add_test(NAME newuoa_${name}_c COMMAND ${name}_c_exe newuoa)
add_test(NAME uobyqa_${name}_c COMMAND ${name}_c_exe uobyqa)
if(APPLE)
add_test(NAME bobyqa_${name}_c COMMAND ${name}_c_exe bobyqa)
add_test(NAME cobyla_${name}_c COMMAND ${name}_c_exe cobyla)
add_test(NAME lincoa_${name}_c COMMAND ${name}_c_exe lincoa)
add_test(NAME newuoa_${name}_c COMMAND ${name}_c_exe newuoa)
add_test(NAME uobyqa_${name}_c COMMAND ${name}_c_exe uobyqa)
elseif(UNIX)
# We prefer to run with gdb so that CI will give us some information in the event of a segfault or other crash.
# GitHub actions will not run gdb on Apple due to its security policy.
add_test(NAME bobyqa_${name}_c COMMAND gdb -batch -ex run -ex where -ex quit --args ${name}_c_exe bobyqa)
add_test(NAME cobyla_${name}_c COMMAND gdb -batch -ex run -ex where -ex quit --args ${name}_c_exe cobyla)
add_test(NAME lincoa_${name}_c COMMAND gdb -batch -ex run -ex where -ex quit --args ${name}_c_exe lincoa)
add_test(NAME newuoa_${name}_c COMMAND gdb -batch -ex run -ex where -ex quit --args ${name}_c_exe newuoa)
add_test(NAME uobyqa_${name}_c COMMAND gdb -batch -ex run -ex where -ex quit --args ${name}_c_exe uobyqa)
elseif(WIN32)
add_test(NAME bobyqa_${name}_c COMMAND gdb -batch -ex run -ex where -ex "if \$_exitcode != 0 quit \$_exitcode" -ex quit --args ../../bin/${name}_c_exe.exe bobyqa)
add_test(NAME cobyla_${name}_c COMMAND gdb -batch -ex run -ex where -ex "if \$_exitcode != 0 quit \$_exitcode" -ex quit --args ../../bin/${name}_c_exe.exe cobyla)
add_test(NAME lincoa_${name}_c COMMAND gdb -batch -ex run -ex where -ex "if \$_exitcode != 0 quit \$_exitcode" -ex quit --args ../../bin/${name}_c_exe.exe lincoa)
add_test(NAME newuoa_${name}_c COMMAND gdb -batch -ex run -ex where -ex "if \$_exitcode != 0 quit \$_exitcode" -ex quit --args ../../bin/${name}_c_exe.exe newuoa)
add_test(NAME uobyqa_${name}_c COMMAND gdb -batch -ex run -ex where -ex "if \$_exitcode != 0 quit \$_exitcode" -ex quit --args ../../bin/${name}_c_exe.exe uobyqa)
endif()

endmacro ()

prima_add_c_test_multi(stress)
Expand Down
10 changes: 9 additions & 1 deletion fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,15 @@ macro (prima_add_f_test name)
if (PRIMA_ENABLE_EXAMPLES)
set_target_properties (example_${name}_fortran_exe PROPERTIES EXCLUDE_FROM_ALL FALSE)
endif ()
add_test (NAME example_${name}_fortran COMMAND example_${name}_fortran_exe)
if(APPLE)
add_test (NAME example_${name}_fortran COMMAND example_${name}_fortran_exe)
elseif(UNIX)
# We prefer to run with gdb so that CI will give us some information in the event of a segfault or other crash.
# GitHub actions will not run gdb on Apple due to its security policy.
add_test (NAME example_${name}_fortran COMMAND gdb -batch -ex run -ex where -ex quit example_${name}_fortran_exe)
elseif(WIN32)
add_test (NAME example_${name}_fortran COMMAND gdb -batch -ex run -ex where -ex "if \$_exitcode != 0 quit \$_exitcode" -ex quit ../bin/example_${name}_fortran_exe.exe)
endif()
add_dependencies(examples example_${name}_fortran_exe)
endmacro ()

Expand Down

0 comments on commit b657be1

Please sign in to comment.