1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2021 Hengqi Chen */ 3 4 #include <test_progs.h> 5 #include "test_prog_array_init.skel.h" 6 test_prog_array_init(void)7void test_prog_array_init(void) 8 { 9 struct test_prog_array_init *skel; 10 int err; 11 12 skel = test_prog_array_init__open(); 13 if (!ASSERT_OK_PTR(skel, "could not open BPF object")) 14 return; 15 16 skel->rodata->my_pid = getpid(); 17 18 err = test_prog_array_init__load(skel); 19 if (!ASSERT_OK(err, "could not load BPF object")) 20 goto cleanup; 21 22 skel->links.entry = bpf_program__attach_raw_tracepoint(skel->progs.entry, "sys_enter"); 23 if (!ASSERT_OK_PTR(skel->links.entry, "could not attach BPF program")) 24 goto cleanup; 25 26 usleep(1); 27 28 ASSERT_EQ(skel->bss->value, 42, "unexpected value"); 29 30 cleanup: 31 test_prog_array_init__destroy(skel); 32 } 33