From 8b7b1c08a508d4d0f7c9effdf2a5af816191744b Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Sat, 11 Oct 2025 22:03:32 +0530 Subject: [PATCH] Add struct_and_helper_binops passing test for assignments --- .../assign/struct_and_helper_binops.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/passing_tests/assign/struct_and_helper_binops.py diff --git a/tests/passing_tests/assign/struct_and_helper_binops.py b/tests/passing_tests/assign/struct_and_helper_binops.py new file mode 100644 index 0000000..7e75de6 --- /dev/null +++ b/tests/passing_tests/assign/struct_and_helper_binops.py @@ -0,0 +1,40 @@ +from pythonbpf import bpf, section, bpfglobal, compile, struct +from ctypes import c_void_p, c_int64, c_uint64 +from pythonbpf.helper import ktime + + +@bpf +@struct +class data_t: + pid: c_uint64 + ts: c_uint64 + + +@bpf +@section("tracepoint/syscalls/sys_enter_execve") +def hello_world(ctx: c_void_p) -> c_int64: + dat = data_t() + dat.pid = 123 + dat.pid = dat.pid + 1 + print(f"pid is {dat.pid}") + x = ktime() - 121 + print(f"ktime is {x}") + x = 1 + x = x + 1 + print(f"x is {x}") + if x == 2: + jat = data_t() + jat.ts = 456 + print(f"Hello, World!, ts is {jat.ts}") + else: + print("Goodbye, World!") + return + + +@bpf +@bpfglobal +def LICENSE() -> str: + return "GPL" + + +compile()