diff --git a/pythonbpf/maps/maps_pass.py b/pythonbpf/maps/maps_pass.py index 26f2aee..920cdfd 100644 --- a/pythonbpf/maps/maps_pass.py +++ b/pythonbpf/maps/maps_pass.py @@ -91,7 +91,7 @@ def create_map_debug_info(module, map_global, map_name, map_params): uint_type = generator.get_uint32_type() ulong_type = generator.get_uint64_type() array_type = generator.create_array_type( - uint_type, map_params.get("type", BPFMapType.HASH).value + uint_type, map_params.get("type", BPFMapType.UNSPEC).value ) type_ptr = generator.create_pointer_type(array_type, 64) key_ptr = generator.create_pointer_type( diff --git a/tests/failing_tests/perf_buffer_map.py b/tests/failing_tests/perf_buffer_map.py deleted file mode 100644 index 1ec3874..0000000 --- a/tests/failing_tests/perf_buffer_map.py +++ /dev/null @@ -1,45 +0,0 @@ -from pythonbpf import bpf, map, struct, section, bpfglobal, compile -from pythonbpf.helpers import ktime, pid -from pythonbpf.maps import PerfEventArray - -from ctypes import c_void_p, c_int32, c_uint64 - - -# PLACEHOLDER EXAMPLE. THIS SHOULD TECHNICALLY STILL FAIL TESTS -@bpf -@struct -class data_t: - pid: c_uint64 - ts: c_uint64 - comm: str(16) - - -@bpf -@map -def events() -> PerfEventArray: - return PerfEventArray(key_size=c_int32, value_size=c_int32) - - -@bpf -@section("tracepoint/syscalls/sys_enter_clone") -def hello(ctx: c_void_p) -> c_int32: - dataobj = data_t() - ts = ktime() - strobj = "hellohellohello" - dataobj.pid = pid() - dataobj.ts = ktime() - # dataobj.comm = strobj - print( - f"clone called at {dataobj.ts} by pid {dataobj.pid}, comm {strobj} at time {ts}" - ) - events.output(dataobj) - return c_int32(0) - - -@bpf -@bpfglobal -def LICENSE() -> str: - return "GPL" - - -compile() diff --git a/tests/passing_tests/perf_buffer_map.py b/tests/passing_tests/perf_buffer_map.py index e69de29..5ae8ea1 100644 --- a/tests/passing_tests/perf_buffer_map.py +++ b/tests/passing_tests/perf_buffer_map.py @@ -0,0 +1,51 @@ +from pythonbpf import bpf, map, struct, section, bpfglobal, compile, compile_to_ir, BPF +from pythonbpf.helpers import ktime, pid +from pythonbpf.maps import PerfEventArray + +from ctypes import c_void_p, c_int32, c_uint64 + + +# PLACEHOLDER EXAMPLE. THIS SHOULD TECHNICALLY STILL FAIL TESTS +@bpf +@struct +class data_t: + pid: c_uint64 + ts: c_uint64 + comm: str(16) + + +@bpf +@map +def events() -> PerfEventArray: + return PerfEventArray(key_size=c_int32, value_size=c_int32) + + +@bpf +@section("tracepoint/syscalls/sys_enter_clone") +def hello(ctx: c_void_p) -> c_int32: + dataobj = data_t() + ts = ktime() + strobj = "hellohellohello" + dataobj.pid = pid() + dataobj.ts = ktime() + # dataobj.comm = strobj + print( + f"clone called at {dataobj.ts} by pid {dataobj.pid}, comm {strobj} at time {ts}" + ) + events.output(dataobj) + return c_int32(0) + + +@bpf +@bpfglobal +def LICENSE() -> str: + return "GPL" + + +compile() +compile_to_ir("perf_buffer_map.py", "perf_buffer_map.ll") +b = BPF() +b.load_and_attach() + +while True: + print("running") diff --git a/tests/failing_tests/ringbuf.py b/tests/passing_tests/ringbuf.py similarity index 100% rename from tests/failing_tests/ringbuf.py rename to tests/passing_tests/ringbuf.py