Skip to content

Commit

Permalink
selftests/bpf: add verif_stats test
Browse files Browse the repository at this point in the history
verified_insns field was added to response of bpf_obj_get_info_by_fd
call on a prog. Confirm that it's being populated by loading a simple
program and asking for its info.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
  • Loading branch information
davemarchevsky authored and Nobody committed Oct 21, 2021
1 parent caf4da4 commit 3c334f6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/verif_stats.c
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2021 Facebook */

#include <test_progs.h>

#include "trace_vprintk.lskel.h"

void test_verif_stats(void)
{
__u32 len = sizeof(struct bpf_prog_info);
struct bpf_prog_info info = {};
struct trace_vprintk *skel;
int err;

skel = trace_vprintk__open_and_load();
if (!ASSERT_OK_PTR(skel, "trace_vprintk__open_and_load"))
goto cleanup;

err = bpf_obj_get_info_by_fd(skel->progs.sys_enter.prog_fd, &info, &len);
if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd"))
goto cleanup;

if (!ASSERT_GT(info.verified_insns, 0, "verified_insns"))
goto cleanup;

cleanup:
trace_vprintk__destroy(skel);
}

0 comments on commit 3c334f6

Please sign in to comment.