mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-02-12 16:10:59 +00:00
Add passing ptr_to_char_array test for strings
This commit is contained in:
28
tests/passing_tests/assign/ptr_to_char_array.py
Normal file
28
tests/passing_tests/assign/ptr_to_char_array.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from pythonbpf import bpf, struct, section, bpfglobal
|
||||||
|
from pythonbpf.helper import comm
|
||||||
|
|
||||||
|
from ctypes import c_void_p, c_int64
|
||||||
|
|
||||||
|
|
||||||
|
@bpf
|
||||||
|
@struct
|
||||||
|
class data_t:
|
||||||
|
comm: str(16) # type: ignore [valid-type]
|
||||||
|
copp: str(16) # type: ignore [valid-type]
|
||||||
|
|
||||||
|
|
||||||
|
@bpf
|
||||||
|
@section("tracepoint/syscalls/sys_enter_clone")
|
||||||
|
def hello(ctx: c_void_p) -> c_int64:
|
||||||
|
dataobj = data_t()
|
||||||
|
comm(dataobj.comm)
|
||||||
|
strobj = dataobj.comm
|
||||||
|
dataobj.copp = strobj
|
||||||
|
print(f"clone called by comm {dataobj.copp}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
@bpf
|
||||||
|
@bpfglobal
|
||||||
|
def LICENSE() -> str:
|
||||||
|
return "GPL"
|
||||||
Reference in New Issue
Block a user