Skip to content

Commit a756f5e

Browse files
committed
Add passing helper test for assignment
1 parent 7529820 commit a756f5e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from pythonbpf import bpf, map, section, bpfglobal, compile
2+
from ctypes import c_void_p, c_int64, c_uint64
3+
from pythonbpf.maps import HashMap
4+
5+
# NOTE: An example of i64** assignment with binops on the RHS
6+
7+
8+
@bpf
9+
@map
10+
def last() -> HashMap:
11+
return HashMap(key=c_uint64, value=c_uint64, max_entries=3)
12+
13+
14+
@bpf
15+
@section("tracepoint/syscalls/sys_enter_execve")
16+
def hello_world(ctx: c_void_p) -> c_int64:
17+
last.update(0, 1)
18+
x = last.lookup(0)
19+
print(f"{x}")
20+
x = x + 1
21+
if x == 2:
22+
print("Hello, World!")
23+
else:
24+
print("Goodbye, World!")
25+
return
26+
27+
28+
@bpf
29+
@bpfglobal
30+
def LICENSE() -> str:
31+
return "GPL"
32+
33+
34+
compile()

0 commit comments

Comments
 (0)