From 80116498d076b840162d74541564a29c4a37335f Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 25 Mar 2025 07:09:04 +0000 Subject: mtest: set VALGRIND_OPTS to fail tests on errors We currently suggest that users run `meson test --wrapper valgrind`, but this doesn't do what one might expect: Valgrind doesn't error out on violations/issues it detects. In the past, we had special handling for Valgrind in tests, see 1f76b76a84cb635f764ecbd2b77aaba1d375d72b but it was later dropped in 951262d7590343ffa9730666c427ad9d708a9fb6. This is similar to what we do for {A,UB,M}SAN_OPTIONS to give sensible behaviour that users expect out-of-the-box. Only do this if we see 'valgrind' in the wrapper command to avoid polluting logs. We may want to do that for the sanitizers variables in future too. Note that we're not adding --exit-on-first-error=yes here, as there may be several issues in an application, or a test may be rather slow, and so on. But --error-exitcode=1 to simply make Valgrind's exit status reflect whether an error was found is uncontroversial. Bug: https://github.com/mesonbuild/meson/issues/4727 Bug: https://github.com/mesonbuild/meson/issues/1105 Bug: https://github.com/mesonbuild/meson/issues/1175 Bug: https://github.com/mesonbuild/meson/issues/13745 --- docs/markdown/snippets/valgrind_test.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/markdown/snippets/valgrind_test.md (limited to 'docs/markdown/snippets') diff --git a/docs/markdown/snippets/valgrind_test.md b/docs/markdown/snippets/valgrind_test.md new file mode 100644 index 0000000..0787300 --- /dev/null +++ b/docs/markdown/snippets/valgrind_test.md @@ -0,0 +1,6 @@ +## Valgrind now fails tests if errors are found + +Valgrind does not reflect an error in its exit code by default, meaning +a test may silently pass despite memory errors. Meson now exports +`VALGRIND_OPTS` such that Valgrind will exit with status 1 to indicate +an error if `VALGRIND_OPTS` is not set in the environment. -- cgit v1.1