[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ac20b89cb46ddfb59150971d0bd836617515565c.1711415233.git.hodges.daniel.scott@gmail.com>
Date: Mon, 25 Mar 2024 21:14:46 -0400
From: Daniel Hodges <hodges.daniel.scott@...il.com>
To: hodges.daniel.scott@...il.com
Cc: ast@...nel.org,
bpf@...r.kernel.org,
daniel@...earbox.net,
lee@...nel.org,
linux-kernel@...r.kernel.org,
linux-leds@...r.kernel.org,
pavel@....cz
Subject: [PATCH v2 2/3] selftests/bpf: Add selftests for bpf led programs
Add selftests for led trigger bpf programs. To run the tests use the
"test_progs -t ledtrig_bpf" helper.
Signed-off-by: Daniel Hodges <hodges.daniel.scott@...il.com>
---
tools/testing/selftests/bpf/config | 1 +
.../testing/selftests/bpf/progs/ledtrig_bpf.c | 32 +++++++++++++++++++
2 files changed, 33 insertions(+)
create mode 100644 tools/testing/selftests/bpf/progs/ledtrig_bpf.c
diff --git a/tools/testing/selftests/bpf/config b/tools/testing/selftests/bpf/config
index 01f241ea2c67..17a027905dcd 100644
--- a/tools/testing/selftests/bpf/config
+++ b/tools/testing/selftests/bpf/config
@@ -42,6 +42,7 @@ CONFIG_IPV6_SEG6_BPF=y
CONFIG_IPV6_SIT=y
CONFIG_IPV6_TUNNEL=y
CONFIG_KEYS=y
+CONFIG_LEDS_TRIGGER_BPF=y
CONFIG_LIRC=y
CONFIG_LWTUNNEL=y
CONFIG_MODULE_SIG=y
diff --git a/tools/testing/selftests/bpf/progs/ledtrig_bpf.c b/tools/testing/selftests/bpf/progs/ledtrig_bpf.c
new file mode 100644
index 000000000000..d2096f13e5b6
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/ledtrig_bpf.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <vmlinux.h>
+
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+#include <bpf/bpf_core_read.h>
+
+
+extern void bpf_ledtrig_blink(const char *led_name, unsigned long delay_on,
+ unsigned long delay_off, int invert) __weak __ksym;
+
+
+SEC("perf_event")
+int perf_blink(void)
+{
+ const char *led = "test_led";
+
+ bpf_ledtrig_blink(led, 30, 30, 0);
+ return 0;
+}
+
+
+SEC("syscall")
+int fork_blink(void)
+{
+ const char *led = "test_led";
+
+ bpf_ledtrig_blink(led, 30, 30, 0);
+ return 0;
+}
+
+char LICENSE[] SEC("license") = "GPL";
--
2.43.2
Powered by blists - more mailing lists