exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 372d74f56fb5c6ca3d25a11ff2a97f9cbd283296
parent 1be40676df72cef771c58b156f9e7bd7c244e004
Author: Özgür Kesim <oec@codeblau.de>
Date:   Mon, 21 Sep 2026 16:53:21 +0200

build: valgrind test setup for the exchangedb table tests

The nix dev shell now ships valgrind (Linux only).  A new meson test
setup `valgrind` sets TALER_VALGRIND, which makes test_table.sh run the
test binary under valgrind and fail on any error or definite leak:

  meson test -C build --setup=valgrind --suite exchangedb

test_misc: free the account the isolation check builds twice, the
setup caught that.

Diffstat:
Mflake.nix | 2++
Mmeson.build | 11+++++++++++
Msrc/exchangedb/test_misc.c | 1+
Msrc/exchangedb/test_table.sh | 12+++++++++++-
4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/flake.nix b/flake.nix @@ -103,6 +103,8 @@ pkgs.pdftk # optional pkgs.doxygen pkgs.libfaketime + ] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ + pkgs.valgrind ]; shellHook = '' diff --git a/meson.build b/meson.build @@ -346,6 +346,17 @@ if not get_option('only-doc') 'TALER_AUDITOR_PREFIX=' + taler_prefix, ], ) + # Unit tests under valgrind; honoured by src/exchangedb/test_table.sh + add_test_setup( + 'valgrind', + env: [ + 'TALER_EXCHANGE_PREFIX=' + taler_prefix, + 'TALER_AUDITOR_PREFIX=' + taler_prefix, + 'TALER_VALGRIND=1', + ], + exclude_suites: ['perf', 'installcheck', 'integrationtests'], + timeout_multiplier: 20, + ) else subdir('contrib') if not get_option('disable-doc') diff --git a/src/exchangedb/test_misc.c b/src/exchangedb/test_misc.c @@ -205,6 +205,7 @@ check_isolation (struct TALER_EXCHANGEDB_PostgresContext *pg) TALER_EXCHANGEDB_rollback (pg); FAILIF (0 != TDB_count (pg, "FROM wire_targets")); + TDB_account_free (&account); FAILIF (GNUNET_OK != TALER_EXCHANGEDB_start (pg, diff --git a/src/exchangedb/test_table.sh b/src/exchangedb/test_table.sh @@ -58,6 +58,16 @@ EOF createdb "$DBNAME" > /dev/null 2>&1 || exit 77 +# With TALER_VALGRIND set (the `valgrind' meson test setup does that), +# run the binary under valgrind and fail the test on any error or +# definite leak. Only the test binary is traced, not the psql tooling. +RUNNER="" +if [ -n "${TALER_VALGRIND:-}" ] +then + command -v valgrind > /dev/null 2>&1 || exit 77 + RUNNER="valgrind -q --leak-check=full --errors-for-leak-kinds=definite --error-exitcode=99 --trace-children=no" +fi + RET=0 -"./$BINARY" -c "$CONF" "$@" || RET=$? +$RUNNER "./$BINARY" -c "$CONF" "$@" || RET=$? exit $RET