From ebc336faa3d353dd7bca0424ed981ac94e8f5fa8 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 4 May 2024 20:09:02 +0200 Subject: [PATCH] test(valgrind): Add a script to test for memory leaks --- flake.nix | 2 ++ scripts/valgrind_test.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 scripts/valgrind_test.sh diff --git a/flake.nix b/flake.nix index 238e2ce..ab9b5fb 100644 --- a/flake.nix +++ b/flake.nix @@ -100,6 +100,8 @@ rust cargo-edit cargo-expand + + valgrind ]; inherit nativeBuildInputs buildInputs; }; diff --git a/scripts/valgrind_test.sh b/scripts/valgrind_test.sh new file mode 100755 index 0000000..3ffbe00 --- /dev/null +++ b/scripts/valgrind_test.sh @@ -0,0 +1,40 @@ +#! /usr/bin/env sh +# Copyright (C) 2023 - 2024: +# The Trinitrix Project +# SPDX-License-Identifier: LGPL-3.0-or-later +# +# This file is part of the Trixy crate for Trinitrix. +# +# Trixy is free software: you can redistribute it and/or modify +# it under the terms of the Lesser GNU General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# and the Lesser GNU General Public License along with this program. +# If not, see . + +cd "$(dirname "$0")" || { + echo "BUG: There is no parent dirname!"; + exit 1 +} +cd .. + +make +cargo build + +export TRINITRIX_LOG=info + +valgrind --leak-check=full \ + --show-leak-kinds=all \ + --show-error-list=yes \ + --track-origins=yes \ + --log-file=./target/valgrind_out.txt \ + ./target/debug/trinitrix --plugin-path ./target/c_build/plugin.so + +cat ./target/valgrind_out.txt