Skip to content

Commit a764b09

Browse files
committed
Add helper_cond failing test for conditionals
1 parent 95a196a commit a764b09

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pythonbpf import bpf, map, section, bpfglobal
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+
if last.lookup(0) > 0:
17+
print("Hello, World!")
18+
else:
19+
print("Goodbye, World!")
20+
return
21+
22+
23+
@bpf
24+
@bpfglobal
25+
def LICENSE() -> str:
26+
return "GPL"

0 commit comments

Comments
 (0)