return mod;
}
+bool bpf_module_rw_engine_enabled() {
+ return ebpf::bpf_module_rw_engine_enabled();
+}
+
void bpf_module_destroy(void *program) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return;
void * bpf_module_create_c_from_string(const char *text, unsigned flags, const char *cflags[],
int ncflags, bool allow_rlimit,
const char *dev_name);
+bool bpf_module_rw_engine_enabled();
void bpf_module_destroy(void *program);
char * bpf_module_license(void *program);
unsigned bpf_module_kern_version(void *program);
lib.bpf_module_create_c_from_string.restype = ct.c_void_p
lib.bpf_module_create_c_from_string.argtypes = [ct.c_char_p, ct.c_uint,
ct.POINTER(ct.c_char_p), ct.c_int, ct.c_bool, ct.c_char_p]
+lib.bpf_module_rw_engine_enabled.restype = ct.c_bool
+lib.bpf_module_rw_engine_enabled.argtypes = None
lib.bpf_module_destroy.restype = None
lib.bpf_module_destroy.argtypes = [ct.c_void_p]
lib.bpf_module_license.restype = ct.c_char_p
#include "BPF.h"
#include "catch.hpp"
-TEST_CASE("test bpf table", "[bpf_table]") {
+TEST_CASE("test bpf table", ebpf::bpf_module_rw_engine_enabled() ? "[bpf_table]" : "[bpf_table][!mayfail]") {
const std::string BPF_PROGRAM = R"(
BPF_TABLE("hash", int, int, myhash, 128);
)";
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
-TEST_CASE("test bpf percpu tables", "[bpf_percpu_table]") {
+TEST_CASE("test bpf percpu tables", ebpf::bpf_module_rw_engine_enabled() ? "[bpf_percpu_table]" : "[bpf_percpu_table][!mayfail]") {
const std::string BPF_PROGRAM = R"(
BPF_PERCPU_HASH(myhash, int, u64, 128);
)";
# Licensed under the Apache License, Version 2.0 (the "License")
from bcc import BPF
+from bcc.libbcc import lib
import ctypes as ct
from unittest import main, skipUnless, TestCase
from utils import kernel_version_ge
b = BPF(text=text, debug=0)
fns = b.load_funcs(BPF.KPROBE)
+ @skipUnless(lib.bpf_module_rw_engine_enabled(), "requires enabled rwengine")
def test_sscanf(self):
text = """
BPF_HASH(stats, int, struct { u64 a; u64 b; u64 c:36; u64 d:28; struct { u32 a; u32 b; } s; }, 10);
self.assertEqual(l.s.a, 5)
self.assertEqual(l.s.b, 6)
+ @skipUnless(lib.bpf_module_rw_engine_enabled(), "requires enabled rwengine")
def test_sscanf_array(self):
text = """
BPF_HASH(stats, int, struct { u32 a[3]; u32 b; }, 10);
self.assertEqual(l.a[2], 3)
self.assertEqual(l.b, 4)
+ @skipUnless(lib.bpf_module_rw_engine_enabled(), "requires enabled rwengine")
def test_sscanf_string(self):
text = """
struct Symbol {