Skip to content

Commit 70a04f5

Browse files
committed
Add passing test for bpf_probe_read helper
1 parent ec2ea83 commit 70a04f5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pythonbpf import bpf, section, bpfglobal, compile, struct
2+
from ctypes import c_void_p, c_int64, c_uint64, c_uint32
3+
from pythonbpf.helper import probe_read
4+
5+
6+
@bpf
7+
@struct
8+
class data_t:
9+
pid: c_uint32
10+
value: c_uint64
11+
12+
13+
@bpf
14+
@section("tracepoint/syscalls/sys_enter_execve")
15+
def test_probe_read(ctx: c_void_p) -> c_int64:
16+
"""Test bpf_probe_read helper function"""
17+
data = data_t()
18+
probe_read(data.value, 8, ctx)
19+
probe_read(data.pid, 4, ctx)
20+
return 0
21+
22+
23+
@bpf
24+
@bpfglobal
25+
def LICENSE() -> str:
26+
return "GPL"
27+
28+
29+
compile()

0 commit comments

Comments
 (0)