Skip to content

Commit e7912a0

Browse files
committed
Add passing or.py test for conditionals
1 parent 95d63d9 commit e7912a0

File tree

1 file changed

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

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
# last.update(1, 2)
17+
x = last.lookup(0)
18+
y = last.lookup(1)
19+
if x or y:
20+
print("Hello, World!")
21+
else:
22+
print("Goodbye, World!")
23+
return
24+
25+
26+
@bpf
27+
@bpfglobal
28+
def LICENSE() -> str:
29+
return "GPL"
30+
31+
32+
compile()

0 commit comments

Comments
 (0)