Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pythonbpf/maps/maps_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
45 changes: 0 additions & 45 deletions tests/failing_tests/perf_buffer_map.py

This file was deleted.

51 changes: 51 additions & 0 deletions tests/passing_tests/perf_buffer_map.py
Original file line number Diff line number Diff line change
@@ -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")
File renamed without changes.