Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Make sure enum-less bpf_enable_stats() API works in C++ mode

Just a simple test to make sure we don't introduce unwanted compiler
warnings and API still supports passing enums as input argument.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20221130200013.2997831-2-andrii@kernel.org

authored by

Andrii Nakryiko and committed by
Daniel Borkmann
f8186bf6 b4269341

+10 -3
+10 -3
tools/testing/selftests/bpf/test_cpp.cpp
··· 1 1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ 2 2 #include <iostream> 3 - #pragma GCC diagnostic push 4 - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 3 + #include <unistd.h> 4 + #include <linux/bpf.h> 5 + #include <linux/btf.h> 5 6 #include <bpf/libbpf.h> 6 - #pragma GCC diagnostic pop 7 7 #include <bpf/bpf.h> 8 8 #include <bpf/btf.h> 9 9 #include "test_core_extern.skel.h" ··· 99 99 struct btf_dump_opts opts = { }; 100 100 struct test_core_extern *skel; 101 101 struct btf *btf; 102 + int fd; 102 103 103 104 try_skeleton_template(); 104 105 ··· 117 116 /* BPF skeleton */ 118 117 skel = test_core_extern__open_and_load(); 119 118 test_core_extern__destroy(skel); 119 + 120 + fd = bpf_enable_stats(BPF_STATS_RUN_TIME); 121 + if (fd < 0) 122 + std::cout << "FAILED to enable stats: " << fd << std::endl; 123 + else 124 + ::close(fd); 120 125 121 126 std::cout << "DONE!" << std::endl; 122 127