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"
9 static int sanity_run(struct bpf_program
*prog
)
11 struct bpf_prog_test_run_attr test_attr
= {};
12 __u64 args
[] = {1, 2, 3};
16 prog_fd
= bpf_program__fd(prog
);
17 test_attr
.prog_fd
= prog_fd
;
18 test_attr
.ctx_in
= args
;
19 test_attr
.ctx_size_in
= sizeof(args
);
20 err
= bpf_prog_test_run_xattr(&test_attr
);
21 if (CHECK(err
|| test_attr
.retval
, "test_run",
22 "err %d errno %d retval %d duration %d\n",
23 err
, errno
, test_attr
.retval
, duration
))
28 void test_test_profiler(void)
30 struct profiler1
*profiler1_skel
= NULL
;
31 struct profiler2
*profiler2_skel
= NULL
;
32 struct profiler3
*profiler3_skel
= NULL
;
36 profiler1_skel
= profiler1__open_and_load();
37 if (CHECK(!profiler1_skel
, "profiler1_skel_load", "profiler1 skeleton failed\n"))
40 err
= profiler1__attach(profiler1_skel
);
41 if (CHECK(err
, "profiler1_attach", "profiler1 attach failed: %d\n", err
))
44 if (sanity_run(profiler1_skel
->progs
.raw_tracepoint__sched_process_exec
))
47 profiler2_skel
= profiler2__open_and_load();
48 if (CHECK(!profiler2_skel
, "profiler2_skel_load", "profiler2 skeleton failed\n"))
51 err
= profiler2__attach(profiler2_skel
);
52 if (CHECK(err
, "profiler2_attach", "profiler2 attach failed: %d\n", err
))
55 if (sanity_run(profiler2_skel
->progs
.raw_tracepoint__sched_process_exec
))
58 profiler3_skel
= profiler3__open_and_load();
59 if (CHECK(!profiler3_skel
, "profiler3_skel_load", "profiler3 skeleton failed\n"))
62 err
= profiler3__attach(profiler3_skel
);
63 if (CHECK(err
, "profiler3_attach", "profiler3 attach failed: %d\n", err
))
66 if (sanity_run(profiler3_skel
->progs
.raw_tracepoint__sched_process_exec
))
69 profiler1__destroy(profiler1_skel
);
70 profiler2__destroy(profiler2_skel
);
71 profiler3__destroy(profiler3_skel
);