Skip to content

Commit 0006e26

Browse files
committed
Add passing test for bpf_get_prandom_u32 implementation
1 parent 5cbd9a5 commit 0006e26

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pythonbpf import bpf, bpfglobal, section, BPF, trace_pipe
2+
from ctypes import c_void_p, c_int64
3+
from pythonbpf.helper import random
4+
5+
6+
@bpf
7+
@section("tracepoint/syscalls/sys_enter_clone")
8+
def hello_world(ctx: c_void_p) -> c_int64:
9+
r = random()
10+
print(f"Hello, World!, {r}")
11+
return 0 # type: ignore [return-value]
12+
13+
14+
@bpf
15+
@bpfglobal
16+
def LICENSE() -> str:
17+
return "GPL"
18+
19+
20+
# Compile and load
21+
b = BPF()
22+
b.load()
23+
b.attach_all()
24+
25+
trace_pipe()

0 commit comments

Comments
 (0)