1
2
3#define _GNU_SOURCE
4#include <test_progs.h>
5#include "test_core_retro.skel.h"
6
7void test_core_retro(void)
8{
9 int err, zero = 0, res, duration = 0, my_pid = getpid();
10 struct test_core_retro *skel;
11
12
13 skel = test_core_retro__open_and_load();
14 if (CHECK(!skel, "skel_load", "skeleton open/load failed\n"))
15 goto out_close;
16
17 err = bpf_map_update_elem(bpf_map__fd(skel->maps.exp_tgid_map), &zero, &my_pid, 0);
18 if (CHECK(err, "map_update", "failed to set expected PID: %d\n", errno))
19 goto out_close;
20
21
22 err = test_core_retro__attach(skel);
23 if (CHECK(err, "attach_kprobe", "err %d\n", err))
24 goto out_close;
25
26
27 usleep(1);
28
29 err = bpf_map_lookup_elem(bpf_map__fd(skel->maps.results), &zero, &res);
30 if (CHECK(err, "map_lookup", "failed to lookup result: %d\n", errno))
31 goto out_close;
32
33 CHECK(res != my_pid, "pid_check", "got %d != exp %d\n", res, my_pid);
34
35out_close:
36 test_core_retro__destroy(skel);
37}
38