Skip to content

Commit 1d6226d

Browse files
committed
Add map test to conditionals
1 parent 12b712c commit 1d6226d

File tree

1 file changed

+30
-0
lines changed
  • tests/passing_tests/conditionals

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
6+
@bpf
7+
@map
8+
def last() -> HashMap:
9+
return HashMap(key=c_uint64, value=c_uint64, max_entries=3)
10+
11+
12+
@bpf
13+
@section("tracepoint/syscalls/sys_enter_execve")
14+
def hello_world(ctx: c_void_p) -> c_int64:
15+
# last.update(0, 1)
16+
tsp = last.lookup(0)
17+
if tsp:
18+
print("Hello, World!")
19+
else:
20+
print("Goodbye, World!")
21+
return
22+
23+
24+
@bpf
25+
@bpfglobal
26+
def LICENSE() -> str:
27+
return "GPL"
28+
29+
30+
compile()

0 commit comments

Comments
 (0)