Skip to content

Commit

Permalink
Merge pull request #11 from NordSecurity/kristupas/add-valgrind-tests
Browse files Browse the repository at this point in the history
Add Valgrind tests
  • Loading branch information
Lipt0nas authored Jan 8, 2024
2 parents 83c7470 + 3fef0b6 commit 75c01fe
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
test-bindings:
runs-on: ubuntu-latest
container:
image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.1.0
image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.2.0
steps:
- uses: actions/checkout@v3
- name: Test bindings
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ FROM gcc:10-bullseye

LABEL org.opencontainers.image.source=https://github.com/NordSecurity/uniffi-bindgen-cpp

RUN apt-get update && apt-get install -y --no-install-recommends cmake curl && apt-get clean
RUN apt-get update && apt-get install -y --no-install-recommends cmake curl valgrind && apt-get clean

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=1.72
8 changes: 8 additions & 0 deletions cpp-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ target_compile_definitions(${TEST_NAME}-test PRIVATE UNIFFI_BINDING_DIR="${BINDI

add_test(NAME ${TEST_NAME}-test COMMAND ${TEST_NAME}-test)

add_test(NAME ${TEST_NAME}-test-memcheck
COMMAND valgrind
--error-exitcode=1
--tool=memcheck
--leak-check=full
--errors-for-leak-kinds=definite
--show-leak-kinds=definite $<TARGET_FILE:${TEST_NAME}-test>)

add_dependencies(${TEST_NAME}-test bindings)

list(APPEND BINDING_FILES ${BINDINGS_SRC_DIR}/${TEST_NAME}.cpp)
Expand Down
2 changes: 1 addition & 1 deletion docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ docker run \
-ti --rm \
--volume $PWD:/mounted_workdir \
--workdir /mounted_workdir \
ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.1.0 bash
ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.2.0 bash
4 changes: 2 additions & 2 deletions test_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ set -euxo pipefail

mkdir -p cpp-tests/build
cd cpp-tests/build
cmake ..
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
make test
CTEST_OUTPUT_ON_FAILURE=1 make test

0 comments on commit 75c01fe

Please sign in to comment.