Re: [PATCH bpf-next 2/2] selftests/bpf: add inline assembly helpers to access array elements

From: Barret Rhoden
Date: Thu Jan 04 2024 - 16:37:32 EST


On 1/3/24 14:51, Andrii Nakryiko wrote:
+
+/*
+ * Helper to load and run a program.
+ * Call must define skel, map_elems, and bss_elems.
+ * Destroy the skel when you're done.
+ */
+#define load_and_run(PROG) ({
does this have to be a macro? Can you write it as a function?

can do. (if we keep these patches).

i used a macro for the ## PROG below, but i can do something with ints and switches to turn on the autoload for a single prog. or just copy-paste the boilerplate.

+ int err; \
+ skel = array_elem_test__open(); \
+ if (!ASSERT_OK_PTR(skel, "array_elem_test open")) \
+ return; \
+ bpf_program__set_autoload(skel->progs.x_ ## PROG, true); \

thanks,

barret