Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c) 2021 Hengqi Chen */
0003 
0004 #include <test_progs.h>
0005 #include "test_prog_array_init.skel.h"
0006 
0007 void test_prog_array_init(void)
0008 {
0009     struct test_prog_array_init *skel;
0010     int err;
0011 
0012     skel = test_prog_array_init__open();
0013     if (!ASSERT_OK_PTR(skel, "could not open BPF object"))
0014         return;
0015 
0016     skel->rodata->my_pid = getpid();
0017 
0018     err = test_prog_array_init__load(skel);
0019     if (!ASSERT_OK(err, "could not load BPF object"))
0020         goto cleanup;
0021 
0022     skel->links.entry = bpf_program__attach_raw_tracepoint(skel->progs.entry, "sys_enter");
0023     if (!ASSERT_OK_PTR(skel->links.entry, "could not attach BPF program"))
0024         goto cleanup;
0025 
0026     usleep(1);
0027 
0028     ASSERT_EQ(skel->bss->value, 42, "unexpected value");
0029 
0030 cleanup:
0031     test_prog_array_init__destroy(skel);
0032 }