From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH] trace-cmd: Add Makefie target for memory test
Date: Wed, 7 Jun 2023 15:02:02 +0300 [thread overview]
Message-ID: <20230607120202.86447-1-tz.stoyanov@gmail.com> (raw)
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.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
Makefile | 3 +++
utest/Makefile | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/Makefile b/Makefile
index ea83f600..9183ba7a 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
--
2.40.1
next reply other threads:[~2023-06-07 12:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 12:02 Tzvetomir Stoyanov (VMware) [this message]
2023-06-07 17:24 ` [PATCH] trace-cmd: Add Makefie target for memory test Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230607120202.86447-1-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).