[PATCH] libtracefs: Do not segfault in tests if synthetic events are not configured

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux