]> Git Repo - J-linux.git/blob - tools/testing/selftests/bpf/prog_tests/test_profiler.c
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / tools / testing / selftests / bpf / prog_tests / test_profiler.c
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020 Facebook */
3 #include <test_progs.h>
4 #include "progs/profiler.h"
5 #include "profiler1.skel.h"
6 #include "profiler2.skel.h"
7 #include "profiler3.skel.h"
8
9 static int sanity_run(struct bpf_program *prog)
10 {
11         LIBBPF_OPTS(bpf_test_run_opts, test_attr);
12         __u64 args[] = {1, 2, 3};
13         int err, prog_fd;
14
15         prog_fd = bpf_program__fd(prog);
16         test_attr.ctx_in = args;
17         test_attr.ctx_size_in = sizeof(args);
18         err = bpf_prog_test_run_opts(prog_fd, &test_attr);
19         if (!ASSERT_OK(err, "test_run"))
20                 return -1;
21
22         if (!ASSERT_OK(test_attr.retval, "test_run retval"))
23                 return -1;
24
25         return 0;
26 }
27
28 void test_test_profiler(void)
29 {
30         struct profiler1 *profiler1_skel = NULL;
31         struct profiler2 *profiler2_skel = NULL;
32         struct profiler3 *profiler3_skel = NULL;
33         __u32 duration = 0;
34         int err;
35
36         profiler1_skel = profiler1__open_and_load();
37         if (CHECK(!profiler1_skel, "profiler1_skel_load", "profiler1 skeleton failed\n"))
38                 goto cleanup;
39
40         err = profiler1__attach(profiler1_skel);
41         if (CHECK(err, "profiler1_attach", "profiler1 attach failed: %d\n", err))
42                 goto cleanup;
43
44         if (sanity_run(profiler1_skel->progs.raw_tracepoint__sched_process_exec))
45                 goto cleanup;
46
47         profiler2_skel = profiler2__open_and_load();
48         if (CHECK(!profiler2_skel, "profiler2_skel_load", "profiler2 skeleton failed\n"))
49                 goto cleanup;
50
51         err = profiler2__attach(profiler2_skel);
52         if (CHECK(err, "profiler2_attach", "profiler2 attach failed: %d\n", err))
53                 goto cleanup;
54
55         if (sanity_run(profiler2_skel->progs.raw_tracepoint__sched_process_exec))
56                 goto cleanup;
57
58         profiler3_skel = profiler3__open_and_load();
59         if (CHECK(!profiler3_skel, "profiler3_skel_load", "profiler3 skeleton failed\n"))
60                 goto cleanup;
61
62         err = profiler3__attach(profiler3_skel);
63         if (CHECK(err, "profiler3_attach", "profiler3 attach failed: %d\n", err))
64                 goto cleanup;
65
66         if (sanity_run(profiler3_skel->progs.raw_tracepoint__sched_process_exec))
67                 goto cleanup;
68 cleanup:
69         profiler1__destroy(profiler1_skel);
70         profiler2__destroy(profiler2_skel);
71         profiler3__destroy(profiler3_skel);
72 }
This page took 0.030359 seconds and 4 git commands to generate.