From 3fef0b6624b29848d626f526a96649f2b99906fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristupas=20Antanavi=C4=8Dius?= Date: Mon, 8 Jan 2024 11:51:44 +0200 Subject: [PATCH] Add Valgrind tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristupas Antanavičius --- .github/workflows/cpp.yml | 2 +- Dockerfile | 2 +- cpp-tests/CMakeLists.txt | 8 ++++++++ docker.sh | 2 +- test_bindings.sh | 4 ++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index ef59538..a57724f 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 21b56c8..ccb60c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/cpp-tests/CMakeLists.txt b/cpp-tests/CMakeLists.txt index afb8ae0..9514744 100644 --- a/cpp-tests/CMakeLists.txt +++ b/cpp-tests/CMakeLists.txt @@ -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 $) + add_dependencies(${TEST_NAME}-test bindings) list(APPEND BINDING_FILES ${BINDINGS_SRC_DIR}/${TEST_NAME}.cpp) diff --git a/docker.sh b/docker.sh index 7b83e02..370097a 100755 --- a/docker.sh +++ b/docker.sh @@ -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 diff --git a/test_bindings.sh b/test_bindings.sh index 6ebb2f0..b394441 100755 --- a/test_bindings.sh +++ b/test_bindings.sh @@ -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