mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
improve import and add failing test
This commit is contained in:
@ -2,7 +2,7 @@ import ast
|
||||
from llvmlite import ir
|
||||
from .license_pass import license_processing
|
||||
from .functions_pass import func_proc
|
||||
from pythonbpf.maps import maps_proc
|
||||
from .maps import maps_proc
|
||||
from .structs import structs_proc
|
||||
from .globals_pass import globals_processing
|
||||
from .debuginfo import DW_LANG_C11, DwarfBehaviorEnum
|
||||
|
||||
30
tests/failing_tests/direct_assign.py
Normal file
30
tests/failing_tests/direct_assign.py
Normal file
@ -0,0 +1,30 @@
|
||||
from pythonbpf import bpf, map, section, bpfglobal, compile
|
||||
from pythonbpf.helpers import XDP_PASS
|
||||
from pythonbpf.maps import HashMap
|
||||
|
||||
from ctypes import c_void_p, c_int64
|
||||
|
||||
@bpf
|
||||
@map
|
||||
def count() -> HashMap:
|
||||
return HashMap(key=c_int64, value=c_int64, max_entries=1)
|
||||
|
||||
|
||||
@bpf
|
||||
@section("xdp")
|
||||
def hello_world(ctx: c_void_p) -> c_int64:
|
||||
prev = count().lookup(0)
|
||||
if prev:
|
||||
count().update(0, prev + 1)
|
||||
return XDP_PASS
|
||||
else:
|
||||
count().update(0, 1)
|
||||
|
||||
return XDP_PASS
|
||||
|
||||
@bpf
|
||||
@bpfglobal
|
||||
def LICENSE() -> str:
|
||||
return "GPL"
|
||||
|
||||
compile()
|
||||
Reference in New Issue
Block a user