[pacman-dev] [PATCH] meson: add configure-time option to run tests with valgrind
ninja doesn't support dynamic modification of commands via command-line
defines the way Make does.
Resolves a major blocker for FS#64394
Signed-off-by: Eli Schwartz
On 12/11/19 4:37 pm, Eli Schwartz wrote:
ninja doesn't support dynamic modification of commands via command-line defines the way Make does.
Resolves a major blocker for FS#64394
It was discussed on the mailing list to instead allow pactest to detect environmental variables to do this. That would be a better approach, as you could decide on individual runs of the test suite whether to use valgrind.
Signed-off-by: Eli Schwartz
--- meson_options.txt | 4 ++++ test/pacman/meson.build | 3 +++ 2 files changed, 7 insertions(+) diff --git a/meson_options.txt b/meson_options.txt index 4d8cc300..80d9422a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -54,3 +54,7 @@ option('i18n', type : 'boolean', value : true, # tools option('file-seccomp', type: 'feature', value: 'auto', description: 'determine whether file is seccomp-enabled') + +# test options +option('valgrind', type : 'boolean', value : false, + description : 'run pacman tests using valgrind') diff --git a/test/pacman/meson.build b/test/pacman/meson.build index 4e87b4f3..2e0a2f5f 100644 --- a/test/pacman/meson.build +++ b/test/pacman/meson.build @@ -346,6 +346,9 @@ foreach input : pacman_tests if not conf.get('HAVE_LIBGPGME') args += '--without-gpg' endif + if get_option('valgrind') + args += '--valgrind' + endif
test( test_name,
In autotools, if we wanted to run tests with valgrind, we used some Make
magic which passed arguments to pactest.py, but that doesn't work in
meson, because all arguments are encoded at configure time. Instead,
let's short-circuit the build runner logic entirely, and teach pactest
to default to running valgrind, when it detects an environment variable
set independent of the build system.
To run the tests with valgrind, we can now use:
PACTEST_VALGRIND=1 meson test -C builddir/
or
PACTEST_VALGRIND=1 make check
It is also possible, but confusing/inconsistent, to use
make check PY_LOG_FLAGS=--valgrind
We *could* add a meson option -Dvalgrind=true, but that is annoying to
reconfigure between test runs, and overall the consensus is it seems
simpler to opt in each time we want to run valgrind, as was already the
case.
Signed-off-by: Eli Schwartz
On 26/11/19 10:26 am, Eli Schwartz wrote:
In autotools, if we wanted to run tests with valgrind, we used some Make magic which passed arguments to pactest.py, but that doesn't work in meson, because all arguments are encoded at configure time. Instead, let's short-circuit the build runner logic entirely, and teach pactest to default to running valgrind, when it detects an environment variable set independent of the build system.
To run the tests with valgrind, we can now use:
PACTEST_VALGRIND=1 meson test -C builddir/
or
PACTEST_VALGRIND=1 make check
It is also possible, but confusing/inconsistent, to use
make check PY_LOG_FLAGS=--valgrind
We *could* add a meson option -Dvalgrind=true, but that is annoying to reconfigure between test runs, and overall the consensus is it seems simpler to opt in each time we want to run valgrind, as was already the case.
Signed-off-by: Eli Schwartz
Works as advertised! Thanks. A
--- test/pacman/pactest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py index a5891d17..3414f4cc 100755 --- a/test/pacman/pactest.py +++ b/test/pacman/pactest.py @@ -96,7 +96,7 @@ def create_parser(): dest = "gdb", default = False, help = "use gdb while calling pacman") parser.add_option("--valgrind", action = "store_true", - dest = "valgrind", default = False, + dest = "valgrind", default = os.getenv('PACTEST_VALGRIND'), help = "use valgrind while calling pacman") parser.add_option("--manual-confirm", action = "store_true", dest = "manualconfirm", default = False,
participants (2)
-
Allan McRae
-
Eli Schwartz