History

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.

Andrii Nakryiko committed 3 years ago

Commit f8186bf1 parent b4269341 file · +10 −3Browse files

Showing the changes to tools/testing/selftests/bpf/test_cpp.cpp (1 of 1 file). Show all

Unified · Split

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