~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Copyright (c) 2022, Oracle and/or its affiliates. */
  3 
  4 #include <test_progs.h>
  5 #include "test_uprobe_autoattach.skel.h"
  6 
  7 /* uprobe attach point */
  8 static noinline int autoattach_trigger_func(int arg1, int arg2, int arg3,
  9                                             int arg4, int arg5, int arg6,
 10                                             int arg7, int arg8)
 11 {
 12         asm volatile ("");
 13         return arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + 1;
 14 }
 15 
 16 void test_uprobe_autoattach(void)
 17 {
 18         const char *devnull_str = "/dev/null";
 19         struct test_uprobe_autoattach *skel;
 20         int trigger_ret;
 21         FILE *devnull;
 22 
 23         skel = test_uprobe_autoattach__open_and_load();
 24         if (!ASSERT_OK_PTR(skel, "skel_open"))
 25                 return;
 26 
 27         if (!ASSERT_OK(test_uprobe_autoattach__attach(skel), "skel_attach"))
 28                 goto cleanup;
 29 
 30         skel->bss->test_pid = getpid();
 31 
 32         /* trigger & validate uprobe & uretprobe */
 33         trigger_ret = autoattach_trigger_func(1, 2, 3, 4, 5, 6, 7, 8);
 34 
 35         skel->bss->test_pid = getpid();
 36 
 37         /* trigger & validate shared library u[ret]probes attached by name */
 38         devnull = fopen(devnull_str, "r");
 39 
 40         ASSERT_EQ(skel->bss->uprobe_byname_parm1, 1, "check_uprobe_byname_parm1");
 41         ASSERT_EQ(skel->bss->uprobe_byname_ran, 1, "check_uprobe_byname_ran");
 42         ASSERT_EQ(skel->bss->uretprobe_byname_rc, trigger_ret, "check_uretprobe_byname_rc");
 43         ASSERT_EQ(skel->bss->uretprobe_byname_ret, trigger_ret, "check_uretprobe_byname_ret");
 44         ASSERT_EQ(skel->bss->uretprobe_byname_ran, 2, "check_uretprobe_byname_ran");
 45         ASSERT_EQ(skel->bss->uprobe_byname2_parm1, (__u64)(long)devnull_str,
 46                   "check_uprobe_byname2_parm1");
 47         ASSERT_EQ(skel->bss->uprobe_byname2_ran, 3, "check_uprobe_byname2_ran");
 48         ASSERT_EQ(skel->bss->uretprobe_byname2_rc, (__u64)(long)devnull,
 49                   "check_uretprobe_byname2_rc");
 50         ASSERT_EQ(skel->bss->uretprobe_byname2_ran, 4, "check_uretprobe_byname2_ran");
 51 
 52         ASSERT_EQ(skel->bss->a[0], 1, "arg1");
 53         ASSERT_EQ(skel->bss->a[1], 2, "arg2");
 54         ASSERT_EQ(skel->bss->a[2], 3, "arg3");
 55 #if FUNC_REG_ARG_CNT > 3
 56         ASSERT_EQ(skel->bss->a[3], 4, "arg4");
 57 #endif
 58 #if FUNC_REG_ARG_CNT > 4
 59         ASSERT_EQ(skel->bss->a[4], 5, "arg5");
 60 #endif
 61 #if FUNC_REG_ARG_CNT > 5
 62         ASSERT_EQ(skel->bss->a[5], 6, "arg6");
 63 #endif
 64 #if FUNC_REG_ARG_CNT > 6
 65         ASSERT_EQ(skel->bss->a[6], 7, "arg7");
 66 #endif
 67 #if FUNC_REG_ARG_CNT > 7
 68         ASSERT_EQ(skel->bss->a[7], 8, "arg8");
 69 #endif
 70 
 71         fclose(devnull);
 72 cleanup:
 73         test_uprobe_autoattach__destroy(skel);
 74 }
 75 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php