xref: /linux/tools/testing/selftests/bpf/prog_tests/verif_stats.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2021 Facebook */
3 
4 #include <test_progs.h>
5 
6 #include "trace_vprintk.lskel.h"
7 
test_verif_stats(void)8 void test_verif_stats(void)
9 {
10 	__u32 len = sizeof(struct bpf_prog_info);
11 	struct trace_vprintk_lskel *skel;
12 	struct bpf_prog_info info = {};
13 	int err;
14 
15 	skel = trace_vprintk_lskel__open_and_load();
16 	if (!ASSERT_OK_PTR(skel, "trace_vprintk__open_and_load"))
17 		goto cleanup;
18 
19 	err = bpf_prog_get_info_by_fd(skel->progs.sys_enter.prog_fd,
20 				      &info, &len);
21 	if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
22 		goto cleanup;
23 
24 	if (!ASSERT_GT(info.verified_insns, 0, "verified_insns"))
25 		goto cleanup;
26 
27 cleanup:
28 	trace_vprintk_lskel__destroy(skel);
29 }
30