[PATCH] libtracefs: utest: Do not fail if uprobes are not supported by kernel

Steven Rostedt <[email protected]> Thu, 3 Apr 2025 13:50:27 -0400
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
From: "Steven Rostedt (Google)" <[email protected]>

If the kernel does not support uprobes, do not fail the unit tests, but report
that the kernel does not support it.

Signed-off-by: Steven Rostedt (Google) <[email protected]>
---
 utest/tracefs-utest.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 8c9aab4..cc7e689 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -2206,6 +2206,7 @@ static bool check_probes(struct probe_test *probes, int count,
 {
 	enum tracefs_dynevent_type type;
 	struct tep_event *tevent;
+	bool uprobes_supported = true;
 	char *ename;
 	char *address;
 	char *event;
@@ -2240,6 +2241,15 @@ static bool check_probes(struct probe_test *probes, int count,
 			}
 			ret = tracefs_event_enable(instance, system, event);
 			if (in_system) {
+				/* ENOTSUPP is 524 */
+				if (ret && errno == 524) {
+					if (uprobes_supported)
+						printf("[KERNEL DOES NOT HAVE UPROBE EVENTS] ...");
+					uprobes_supported = false;
+					/* Count it as passed */
+					found++;
+					break;
+				}
 				CU_TEST(ret == 0);
 			} else {
 				CU_TEST(ret != 0);
-- 
2.47.2