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

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

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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) 2019 Facebook */
  3 
  4 #include <test_progs.h>
  5 #include "test_ksyms.skel.h"
  6 #include <sys/stat.h>
  7 
  8 void test_ksyms(void)
  9 {
 10         const char *btf_path = "/sys/kernel/btf/vmlinux";
 11         struct test_ksyms *skel;
 12         struct test_ksyms__data *data;
 13         __u64 link_fops_addr, per_cpu_start_addr;
 14         struct stat st;
 15         __u64 btf_size;
 16         int err;
 17 
 18         err = kallsyms_find("bpf_link_fops", &link_fops_addr);
 19         if (!ASSERT_NEQ(err, -EINVAL, "bpf_link_fops: kallsyms_fopen"))
 20                 return;
 21         if (!ASSERT_NEQ(err, -ENOENT, "bpf_link_fops: ksym_find"))
 22                 return;
 23 
 24         err = kallsyms_find("__per_cpu_start", &per_cpu_start_addr);
 25         if (!ASSERT_NEQ(err, -EINVAL, "__per_cpu_start: kallsyms_fopen"))
 26                 return;
 27         if (!ASSERT_NEQ(err, -ENOENT, "__per_cpu_start: ksym_find"))
 28                 return;
 29 
 30         if (!ASSERT_OK(stat(btf_path, &st), "stat_btf"))
 31                 return;
 32         btf_size = st.st_size;
 33 
 34         skel = test_ksyms__open_and_load();
 35         if (!ASSERT_OK_PTR(skel, "test_ksyms__open_and_load"))
 36                 return;
 37 
 38         err = test_ksyms__attach(skel);
 39         if (!ASSERT_OK(err, "test_ksyms__attach"))
 40                 goto cleanup;
 41 
 42         /* trigger tracepoint */
 43         usleep(1);
 44 
 45         data = skel->data;
 46         ASSERT_EQ(data->out__bpf_link_fops, link_fops_addr, "bpf_link_fops");
 47         ASSERT_EQ(data->out__bpf_link_fops1, 0, "bpf_link_fops1");
 48         ASSERT_EQ(data->out__btf_size, btf_size, "btf_size");
 49         ASSERT_EQ(data->out__per_cpu_start, per_cpu_start_addr, "__per_cpu_start");
 50 
 51 cleanup:
 52         test_ksyms__destroy(skel);
 53 }
 54 

~ [ 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