Skip to content

Commit 8b7b1c0

Browse files
committed
Add struct_and_helper_binops passing test for assignments
1 parent c9bbe1f commit 8b7b1c0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from pythonbpf import bpf, section, bpfglobal, compile, struct
2+
from ctypes import c_void_p, c_int64, c_uint64
3+
from pythonbpf.helper import ktime
4+
5+
6+
@bpf
7+
@struct
8+
class data_t:
9+
pid: c_uint64
10+
ts: c_uint64
11+
12+
13+
@bpf
14+
@section("tracepoint/syscalls/sys_enter_execve")
15+
def hello_world(ctx: c_void_p) -> c_int64:
16+
dat = data_t()
17+
dat.pid = 123
18+
dat.pid = dat.pid + 1
19+
print(f"pid is {dat.pid}")
20+
x = ktime() - 121
21+
print(f"ktime is {x}")
22+
x = 1
23+
x = x + 1
24+
print(f"x is {x}")
25+
if x == 2:
26+
jat = data_t()
27+
jat.ts = 456
28+
print(f"Hello, World!, ts is {jat.ts}")
29+
else:
30+
print("Goodbye, World!")
31+
return
32+
33+
34+
@bpf
35+
@bpfglobal
36+
def LICENSE() -> str:
37+
return "GPL"
38+
39+
40+
compile()

0 commit comments

Comments
 (0)