From 1d6226d8293000b5ea907358a74b9adcbf380027 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Tue, 7 Oct 2025 04:06:16 +0530 Subject: [PATCH] Add map test to conditionals --- tests/passing_tests/conditionals/map.py | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/passing_tests/conditionals/map.py diff --git a/tests/passing_tests/conditionals/map.py b/tests/passing_tests/conditionals/map.py new file mode 100644 index 0000000..fa490a7 --- /dev/null +++ b/tests/passing_tests/conditionals/map.py @@ -0,0 +1,30 @@ +from pythonbpf import bpf, map, section, bpfglobal, compile +from ctypes import c_void_p, c_int64, c_uint64 +from pythonbpf.maps import HashMap + + +@bpf +@map +def last() -> HashMap: + return HashMap(key=c_uint64, value=c_uint64, max_entries=3) + + +@bpf +@section("tracepoint/syscalls/sys_enter_execve") +def hello_world(ctx: c_void_p) -> c_int64: + # last.update(0, 1) + tsp = last.lookup(0) + if tsp: + print("Hello, World!") + else: + print("Goodbye, World!") + return + + +@bpf +@bpfglobal +def LICENSE() -> str: + return "GPL" + + +compile()