1 // SPDX-License-Identifier: GPL-2.0
3 #include <test_progs.h>
4 #include <linux/ptrace.h>
5 #include "test_task_pt_regs.skel.h"
7 void test_task_pt_regs(void)
9 struct test_task_pt_regs *skel;
10 struct bpf_link *uprobe_link;
15 base_addr = get_base_addr();
16 if (!ASSERT_GT(base_addr, 0, "get_base_addr"))
18 uprobe_offset = get_uprobe_offset(&get_base_addr, base_addr);
20 skel = test_task_pt_regs__open_and_load();
21 if (!ASSERT_OK_PTR(skel, "skel_open"))
23 if (!ASSERT_OK_PTR(skel->bss, "check_bss"))
26 uprobe_link = bpf_program__attach_uprobe(skel->progs.handle_uprobe,
31 if (!ASSERT_OK_PTR(uprobe_link, "attach_uprobe"))
33 skel->links.handle_uprobe = uprobe_link;
35 /* trigger & validate uprobe */
38 if (!ASSERT_EQ(skel->bss->uprobe_res, 1, "check_uprobe_res"))
41 match = !memcmp(&skel->bss->current_regs, &skel->bss->ctx_regs,
42 sizeof(skel->bss->current_regs));
43 ASSERT_TRUE(match, "check_regs_match");
46 test_task_pt_regs__destroy(skel);