aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>2023-06-07 15:02:02 +0300
committerSteven Rostedt (Google) <rostedt@goodmis.org>2023-06-07 14:29:48 -0400
commitaa21520b483fb8103d4abcc31ced599c538776f2 (patch)
treee6b2cec708e666a65c7671236943c01e7454f158
parent925e15fb0009044450f969f60edf0978a4bd22c6 (diff)
downloadtrace-cmd-aa21520b483fb8103d4abcc31ced599c538776f2.tar.gz
trace-cmd: Add Makefile 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. Link: https://lore.kernel.org/linux-trace-devel/20230607120202.86447-1-tz.stoyanov@gmail.com Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--Makefile3
-rw-r--r--utest/Makefile15
2 files changed, 18 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 4e7c7858..22cc8f0c 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/utest/Makefile b/utest/Makefile
index 337db9bf..480edcd3 100644
--- a/utest/Makefile
+++ b/utest/Makefile
@@ -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