File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1
1
#include <stdio.h>
2
2
#include <sys/epoll.h>
3
+ #include <util/util.h>
3
4
#include <util/bpf-loader.h>
4
5
#include <util/evlist.h>
6
+ #include <linux/bpf.h>
7
+ #include <linux/filter.h>
8
+ #include <bpf/bpf.h>
5
9
#include "tests.h"
6
10
#include "llvm.h"
7
11
#include "debug.h"
@@ -243,6 +247,36 @@ const char *test__bpf_subtest_get_desc(int i)
243
247
return bpf_testcase_table [i ].desc ;
244
248
}
245
249
250
+ static int check_env (void )
251
+ {
252
+ int err ;
253
+ unsigned int kver_int ;
254
+ char license [] = "GPL" ;
255
+
256
+ struct bpf_insn insns [] = {
257
+ BPF_MOV64_IMM (BPF_REG_0 , 1 ),
258
+ BPF_EXIT_INSN (),
259
+ };
260
+
261
+ err = fetch_kernel_version (& kver_int , NULL , 0 );
262
+ if (err ) {
263
+ pr_debug ("Unable to get kernel version\n" );
264
+ return err ;
265
+ }
266
+
267
+ err = bpf_load_program (BPF_PROG_TYPE_KPROBE , insns ,
268
+ sizeof (insns ) / sizeof (insns [0 ]),
269
+ license , kver_int , NULL , 0 );
270
+ if (err < 0 ) {
271
+ pr_err ("Missing basic BPF support, skip this test: %s\n" ,
272
+ strerror (errno ));
273
+ return err ;
274
+ }
275
+ close (err );
276
+
277
+ return 0 ;
278
+ }
279
+
246
280
int test__bpf (int i )
247
281
{
248
282
int err ;
@@ -255,6 +289,9 @@ int test__bpf(int i)
255
289
return TEST_SKIP ;
256
290
}
257
291
292
+ if (check_env ())
293
+ return TEST_SKIP ;
294
+
258
295
err = __test__bpf (i );
259
296
return err ;
260
297
}
You can’t perform that action at this time.
0 commit comments