* [PATCH] libtracefs: Do not segfault in tests if synthetic events are not configured
@ 2023-05-30 4:23 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2023-05-30 4:23 UTC (permalink / raw)
To: Linux Trace Devel
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
If synthetic events are not configured in the kernel, the unit tests will
segfault and crash. Check if synthetic events exist and fail out nicely. The
tests will still fail if synthetic events are not configured, but they at least
will not crash.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
utest/tracefs-utest.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 17fcac722fbc..9cfafdbd039c 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -994,7 +994,9 @@ static void test_synth_compare(struct test_synth *synth, struct tracefs_dynevent
stype = tracefs_dynevent_info(devents[i], NULL,
&event, NULL, NULL, &format);
CU_TEST(stype == TRACEFS_DYNEVENT_SYNTH);
- CU_TEST(strcmp(event, synth[i].name) == 0);
+ if (stype != TRACEFS_DYNEVENT_SYNTH)
+ continue;
+ CU_TEST(event && synth[i].name && strcmp(event, synth[i].name) == 0);
if (synth[i].match_name) {
CU_TEST(strstr(format, synth[i].match_name) != NULL);
}
--
2.39.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-30 4:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30 4:23 [PATCH] libtracefs: Do not segfault in tests if synthetic events are not configured Steven Rostedt
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).