Skip to content

Commit

Permalink
[CI] enable runtime checks, test with Valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Aug 1, 2023
1 parent 4be18a5 commit 218c330
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
types: ['released', 'prereleased']

env:
PYTHON_VERSION: '3.10'
PYTHON_VERSION: '3.11'

jobs:
build:
Expand Down Expand Up @@ -185,6 +185,32 @@ jobs:
cmake --build build-tests -t test --config Debug
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Install Valgrind
run: |
apt update
apt install -y valgrind --no-install-recommends
- name: Run examples (Valgrind, RelWithDebInfo)
run: |
valgrind --gen-suppressions=all ./build-examples/C++/CustomCppProblem/RelWithDebInfo/custom-cpp-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/SimpleUnconstrProblem/RelWithDebInfo/simple-unconstr-cpp-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/CustomControlCppProblem/RelWithDebInfo/custom-control-cpp-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/FortranProblem/RelWithDebInfo/fortran-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/DLProblem/RelWithDebInfo/dl-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/DLProblem/RelWithDebInfo/test-matmul
- name: Run examples (Valgrind, Debug)
run: |
valgrind --gen-suppressions=all ./build-examples/C++/CustomCppProblem/Debug/custom-cpp-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/SimpleUnconstrProblem/Debug/simple-unconstr-cpp-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/CustomControlCppProblem/Debug/custom-control-cpp-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/FortranProblem/Debug/fortran-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/DLProblem/Debug/dl-problem-example
valgrind --gen-suppressions=all ./build-examples/C++/DLProblem/Debug/test-matmul
- name: Run tests (Valgrind, RelWithDebInfo)
run: |
valgrind --gen-suppressions=all ./build-tests/RelWithDebInfo/tests
- name: Run tests (Valgrind, Debug)
run: |
valgrind --gen-suppressions=all ./build-tests/Debug/tests
test-deb:
needs: [build]
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/wheel-short-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
PACKAGE_VERSION: '1.0.0a9'
PACKAGE_NAME: alpaqa
PYTHON_VERSION: '3.10'
PYTHON_VERSION: '3.11'

jobs:
build-linux:
Expand Down Expand Up @@ -64,8 +64,8 @@ jobs:
-C--cross="$PWD/ninja-debug.cross.toml" \
-C--cross="$staging/cmake/$host.py-build-cmake.cross.toml"
env:
CFLAGS: '-static-libgcc'
CXXFLAGS: '-static-libgcc -static-libstdc++'
CFLAGS: '-fstack-protector-all -mshstk -fcf-protection=full -D_FORTIFY_SOURCE=3 -fdiagnostics-color -static-libgcc'
CXXFLAGS: '-fstack-protector-all -mshstk -fcf-protection=full -D_FORTIFY_SOURCE=3 -fdiagnostics-color -static-libgcc -static-libstdc++'
# Upload
- name: Upload Wheels
uses: actions/upload-artifact@v3
Expand All @@ -77,7 +77,7 @@ jobs:
test-linux:
needs: [build-linux]
runs-on: ubuntu-latest
container: python:3.10-bullseye
container: python:3.11-bullseye
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -86,11 +86,20 @@ jobs:
with:
name: whl-${{ env.PYTHON_VERSION }}-linux-test
path: dist
- name: Test
- name: Install test dependencies
run: |
python3 -m pip install -U pip cmake ninja twine
python3 -m pip install --find-links=dist "${PACKAGE_NAME}[test]==${PACKAGE_VERSION}"
pytest -rP
- name: Test (Debug)
run: python3 -m pytest -rP
env:
ALPAQA_PYTHON_DEBUG: "1"
- name: Install Valgrind
run: |
apt update
apt install -y valgrind --no-install-recommends
- name: Test (Valgrind, Debug)
run: valgrind --gen-suppressions=all --suppressions=scripts/valgrind/python.supp python3 -m pytest -rP
env:
ALPAQA_PYTHON_DEBUG: "1"
- name: Check Wheel metadata
Expand Down
4 changes: 3 additions & 1 deletion python/test/test_alm_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def bad_experiment2():
return stats

def run(experiment):
valgrind = 'valgrind' in os.getenv('LD_PRELOAD', '')
N = 4 if valgrind else 200
with concurrent.futures.ThreadPoolExecutor(max_workers=os.cpu_count()) as pool:
futures = (pool.submit(experiment) for _ in range(200))
futures = (pool.submit(experiment) for _ in range(N))
for future in concurrent.futures.as_completed(futures):
stats = future.result()
assert stats["status"] == pa.SolverStatus.MaxIter
Expand Down
7 changes: 7 additions & 0 deletions scripts/valgrind/python.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
dlopen invalid read
Memcheck:Addr8
fun:strncmp
...
fun:dl_open_worker
}

0 comments on commit 218c330

Please sign in to comment.