The 'duration' variable is referenced in the CHECK() macro, and there are some uses of the macro before 'duration' is set. The clang compiler (validly) complains about this. Sample error: .../selftests/bpf/prog_tests/fexit_test.c:23:6: warning: variable 'duration' is uninitialized when used here [-Wuninitialized] if (CHECK(err, "prog_load sched cls", "err %d errno %d\n", err, errno)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .../selftests/bpf/test_progs.h:134:25: note: expanded from macro 'CHECK' if (CHECK(err, "prog_load sched cls", "err %d errno %d\n", err, errno)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _CHECK(condition, tag, duration, format) ^~~~~~~~ Signed-off-by: John Sperbeck <jsperbeck@google.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20200123235144.93610-1-sdf@google.com
44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright (c) 2019 Facebook */
|
|
#include <test_progs.h>
|
|
#include "test_pkt_access.skel.h"
|
|
#include "fentry_test.skel.h"
|
|
|
|
void test_fentry_test(void)
|
|
{
|
|
struct test_pkt_access *pkt_skel = NULL;
|
|
struct fentry_test *fentry_skel = NULL;
|
|
int err, pkt_fd, i;
|
|
__u32 duration = 0, retval;
|
|
__u64 *result;
|
|
|
|
pkt_skel = test_pkt_access__open_and_load();
|
|
if (CHECK(!pkt_skel, "pkt_skel_load", "pkt_access skeleton failed\n"))
|
|
return;
|
|
fentry_skel = fentry_test__open_and_load();
|
|
if (CHECK(!fentry_skel, "fentry_skel_load", "fentry skeleton failed\n"))
|
|
goto cleanup;
|
|
|
|
err = fentry_test__attach(fentry_skel);
|
|
if (CHECK(err, "fentry_attach", "fentry attach failed: %d\n", err))
|
|
goto cleanup;
|
|
|
|
pkt_fd = bpf_program__fd(pkt_skel->progs.test_pkt_access);
|
|
err = bpf_prog_test_run(pkt_fd, 1, &pkt_v6, sizeof(pkt_v6),
|
|
NULL, NULL, &retval, &duration);
|
|
CHECK(err || retval, "ipv6",
|
|
"err %d errno %d retval %d duration %d\n",
|
|
err, errno, retval, duration);
|
|
|
|
result = (__u64 *)fentry_skel->bss;
|
|
for (i = 0; i < 6; i++) {
|
|
if (CHECK(result[i] != 1, "result",
|
|
"fentry_test%d failed err %lld\n", i + 1, result[i]))
|
|
goto cleanup;
|
|
}
|
|
|
|
cleanup:
|
|
fentry_test__destroy(fentry_skel);
|
|
test_pkt_access__destroy(pkt_skel);
|
|
}
|