build: Fix valgrind invocation for HTML tests

Using `$HTML_LOG_FLAGS` to inject valgrind is conceptually brittle, as
it's not clear where exactly that gets shoved into the command line.
At least Fedora 35's and Debian stable's automake versions (1.16.2 and
.3) generate the test command with

    HTML_LOG_COMPILE = $(HTML_LOG_COMPILER) $(AM_HTML_LOG_FLAGS) $(HTML_LOG_FLAGS)

which makes sense in general, but produces a command like

    tap-cdp ./test-server valgrind /source/dist/base1/test-user.html

This makes no sense: valgrind immediately exits with "no program
specified" and tests just hang. What we want is to run test-server
under valgrind.

It's not actually clear how this ever worked. Let's make the CLI
ordering explicit: Stop using `$HTML_LOG_FLAGS` and use our own
`$HTML_TEST_WRAPPER` variable, and inject it into the correct position
between tap-cdp and test-server.

Change `$VALGRIND_ARGS` to `$VALGRIND` and include the actual valgrind
program, so that the whole wrapper is self-contained. With that, we can
potentially run test-server under other tracers.
This commit is contained in:
Martin Pitt 2022-07-13 08:02:25 +02:00 committed by Martin Pitt
parent cd3b3e8af6
commit c287ce38ea
1 changed files with 6 additions and 6 deletions

View File

@ -75,21 +75,21 @@ EXTRA_DIST += \
check: export VERBOSE=1
TEST_EXTENSIONS = .html .sh
HTML_LOG_COMPILER = $(top_srcdir)/test/common/tap-cdp --strip=$(abs_top_srcdir)/ ./test-server $(COCKPIT_BRIDGE)
HTML_LOG_COMPILER = $(top_srcdir)/test/common/tap-cdp --strip=$(abs_top_srcdir)/ $(HTML_TEST_WRAPPER) ./test-server $(COCKPIT_BRIDGE)
VALGRIND_ARGS = --trace-children=yes --quiet --error-exitcode=33 --gen-suppressions=all \
VALGRIND = valgrind --trace-children=yes --quiet --error-exitcode=33 --gen-suppressions=all \
$(foreach file,$(wildcard $(srcdir)/tools/*.supp),--suppressions=$(file)) \
--num-callers=16 --leak-check=yes --show-leak-kinds=definite \
--errors-for-leak-kinds=definite --trace-children-skip='*mock*,/bin*,/usr/bin/*,/usr/local/bin'
check-memory:
$(MAKE) LOG_FLAGS="valgrind $(VALGRIND_ARGS)" \
HTML_LOG_FLAGS="valgrind $(VALGRIND_ARGS)" \
$(MAKE) LOG_FLAGS="$(VALGRIND)" \
HTML_TEST_WRAPPER="$(VALGRIND)" \
COCKPIT_SKIP_SLOW_TESTS=1 \
$(AM_MAKEFLAGS) check TESTS="$(filter-out test/% bots/%,$(TESTS))"
recheck-memory:
$(MAKE) LOG_FLAGS="-- valgrind $(VALGRIND_ARGS)" \
HTML_LOG_FLAGS="valgrind $(VALGRIND_ARGS)" \
$(MAKE) LOG_FLAGS="$(VALGRIND_ARGS)" \
HTML_TEST_WRAPPER="$(VALGRIND)" \
$(AM_MAKEFLAGS) recheck
# checkout Cockpit's bots for standard test VM images and API to launch them