summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/test_autoattach.c
diff options
context:
space:
mode:
authorHao Luo <haoluo@google.com>2022-08-16 16:40:12 -0700
committerAndrii Nakryiko <andrii@kernel.org>2022-08-17 09:42:07 -0700
commit738a2f2f9130f98f92ccb3efd94d4879c0a0990c (patch)
treef59098cb9084556a110c7a27850f5d85929ae774 /tools/testing/selftests/bpf/progs/test_autoattach.c
parent43cb8cbadffa21e88a65dd1129c86f5552d6c42e (diff)
selftests/bpf: Tests libbpf autoattach APIs
Adds test for libbpf APIs that toggle bpf program auto-attaching. Signed-off-by: Hao Luo <haoluo@google.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220816234012.910255-2-haoluo@google.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_autoattach.c')
-rw-r--r--tools/testing/selftests/bpf/progs/test_autoattach.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_autoattach.c b/tools/testing/selftests/bpf/progs/test_autoattach.c
new file mode 100644
index 000000000000..11a44493ebce
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/test_autoattach.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2022 Google */
+
+#include "vmlinux.h"
+#include <bpf/bpf_tracing.h>
+
+bool prog1_called = false;
+bool prog2_called = false;
+
+SEC("raw_tp/sys_enter")
+int prog1(const void *ctx)
+{
+ prog1_called = true;
+ return 0;
+}
+
+SEC("raw_tp/sys_exit")
+int prog2(const void *ctx)
+{
+ prog2_called = true;
+ return 0;
+}
+