trace-cmd: Add Makefie target for memory test
PATCH 1/1 trace-cmd: Add Makefie target for memory test
Having an automated test for memory problems is a useful functionality. Combined with the trace-cmd unit test, it can be used to detect any memory issues in the application. New Makefile target is added, which runs the trace-cmd unit test on valgrind, to check for memory allocation errors.
--- Makefile | 3 +++ utest/Makefile | 15 +++++++++++++++ 2 files changed, 18 insertions(+)
Makefile +3 -0
@@ -456,6 +456,9 @@ ifneq ($(CUNIT_INSTALLED),1) endif $(Q)$(MAKE) -C $(src)/utest $@ +test_mem: force test + $(Q)$(MAKE) -C $(src)/utest $@ + plugins_tracecmd: force $(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir $(Q)$(MAKE) -C $(src)/lib/trace-cmd/plugins
utest/Makefile +15 -0
@@ -17,6 +17,8 @@ LIBS += $(ZLIB_LDLAGS) $(LIBZSTD_LDLAGS) OBJS := $(OBJS:%.o=$(bdir)/%.o) DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d) +VALGRIND = $(shell which valgrind) + $(bdir): @mkdir -p $(bdir)
@@ -39,5 +41,18 @@ dep_includes := $(wildcard $(DEPS)) test: $(TARGETS) +test_mem: test +ifeq (, $(VALGRIND)) + $(error "No valgrind in $(PATH), cannot run memory test") +endif +ifneq ($(shell id -u), 0) + $(error "The memory test should be run as root, as it reuqires full access to tracefs") +endif + CK_FORK=no $(VALGRIND) \ + --show-leak-kinds=all --leak-resolution=high \ + --leak-check=full --show-possibly-lost=yes \ + --track-origins=yes -s \ + $(bdir)/trace-utest + clean: $(RM) $(TARGETS) $(bdir)/*.o $(bdir)/.*.d
Signature · 1 line
2.40.1
Quoted 7 lines · On Wed, 7 Jun 2023 15:02:02 +0300 "Tzvetomir Stoyanov (VMware)"…
Having an automated test for memory problems is a useful functionality. Combined with the trace-cmd unit test, it can be used to detect any memory issues in the application. New
Makefiletarget is added, which runs the trace-cmd unit test on valgrind, to check for memory allocation errors.Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>
Thanks Tzvetomir!
I'll queue this up, along with a few patches to fix up some of the reports. Basically caused by the test, not what it was testing.
-- Steve