Re: [PATCHv2 bpf-next 8/9] selftests/bpf: Add uprobe session recursive test

From: Andrii Nakryiko
Date: Tue Jul 02 2024 - 18:14:55 EST


On Mon, Jul 1, 2024 at 9:43 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> Adding uprobe session test that verifies the cookie value is stored
> properly when single uprobe-ed function is executed recursively.
>
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> .../bpf/prog_tests/uprobe_multi_test.c | 57 +++++++++++++++++++
> .../progs/uprobe_multi_session_recursive.c | 44 ++++++++++++++
> 2 files changed, 101 insertions(+)
> create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_session_recursive.c
>

Nice!

Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>


[...]

> +static void test_session_recursive_skel_api(void)
> +{
> + struct uprobe_multi_session_recursive *skel = NULL;
> + int i, err;
> +
> + skel = uprobe_multi_session_recursive__open_and_load();
> + if (!ASSERT_OK_PTR(skel, "uprobe_multi_session_recursive__open_and_load"))
> + goto cleanup;
> +
> + skel->bss->pid = getpid();
> +
> + err = uprobe_multi_session_recursive__attach(skel);
> + if (!ASSERT_OK(err, "uprobe_multi_session_recursive__attach"))
> + goto cleanup;
> +
> + for (i = 0; i < ARRAY_SIZE(skel->bss->test_uprobe_cookie_entry); i++)
> + skel->bss->test_uprobe_cookie_entry[i] = i + 1;
> +
> + uprobe_session_recursive(5);
> +
> + /*

nit: unnecessary empty comment line

> + * entry uprobe:
> + * uprobe_session_recursive(5) { *cookie = 1, return 0
> + * uprobe_session_recursive(4) { *cookie = 2, return 1
> + * uprobe_session_recursive(3) { *cookie = 3, return 0
> + * uprobe_session_recursive(2) { *cookie = 4, return 1
> + * uprobe_session_recursive(1) { *cookie = 5, return 0
> + * uprobe_session_recursive(0) { *cookie = 6, return 1
> + * return uprobe:
> + * } i = 0 not executed
> + * } i = 1 test_uprobe_cookie_return[0] = 5
> + * } i = 2 not executed
> + * } i = 3 test_uprobe_cookie_return[1] = 3
> + * } i = 4 not executed
> + * } i = 5 test_uprobe_cookie_return[2] = 1
> + */
> +

[...]