Skip to content

Commit

Permalink
Feature/add valgrind GitHub workflow (#89)
Browse files Browse the repository at this point in the history
* install valgrind dependency in github workflow
* build unittests before running valgrind
* add script to run valgrind
* add valgrind to docker
#85 #86 are two issues reported by valgrind
  • Loading branch information
michaeldsmith authored Aug 6, 2022
1 parent 7ba5e3b commit 9d69d3a
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 1 deletion.
34 changes: 33 additions & 1 deletion .github/workflows/cmake_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,38 @@ jobs:
- name: Test
working-directory: ${{github.workspace}}/build
run: make check

valgrind:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

steps:

- name: install dependencies
run: sudo apt-get -y install valgrind

- uses: actions/checkout@v3

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: |
cd ${{ github.workspace }}
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Make unit tests
working-directory: ${{github.workspace}}/build
run: make check


- name: Run Valgrind on unit tests
working-directory: ${{github.workspace}}/build
# Run valgrind using a bash script
run: pwd && ls && bash ../resources/test/scripts/run_valgrind.sh


3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y install cmake
RUN apt-get -y install g++

# install developement debugging tools
RUN apt-get -y install valgrind

# install CTL dependencies
RUN apt-get -y install libilmbase-dev
RUN apt-get -y install libopenexr-dev
Expand Down
61 changes: 61 additions & 0 deletions resources/test/scripts/run_valgrind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

set -x
set -u

# get initial path before changing it
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

cd ./unittest/IlmCtl/
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ./IlmCtlTest
test_01_status=$?
test_01_label="IlmCtlTest"

cd ../IlmCtlMath/
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ./IlmCtlMathTest
test_02_status=$?
test_02_label="IlmCtlMathTest"

cd ../IlmImfCtl/
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ./IlmImfCtlTest
test_03_status=$?
test_03_label="IlmImfCtlTest"

cd ../ctlrender
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/bars_nuke_10_be.dpx out.dpx
test_04_status=$?
test_04_label="ctlrender"

# go back to initial path
cd $SCRIPTPATH

# return valgrind exit codes
if [ $test_01_status -eq 0 ] && [ $test_02_status -eq 0 ] && [ $test_03_status -eq 0 ] && [ $test_04_status -eq 0 ]
then
echo "Success: valgrind detected no errors"
exit 0
else
echo "Failure: valgrind detected errors"

if [ $test_01_status -ne 0 ]
then
echo "$test_01_label: valgrind detected errors"
fi

if [ $test_02_status -ne 0 ]
then
echo "$test_02_label: valgrind detected errors"
fi

if [ $test_03_status -ne 0 ]
then
echo "$test_03_label: valgrind detected errors"
fi

if [ $test_04_status -ne 0 ]
then
echo "$test_04_label: valgrind detected errors"
fi

exit 1
fi

0 comments on commit 9d69d3a

Please sign in to comment.