run_function took the return type from the IR and read only i32 and i64,
as signed. It now takes an optional ctypes type, so a caller can read an
unsigned or narrow result the way C would see it. Without one, it does
what it did before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/c-form/map_update_from_lookup.bpf.c mirrors the two programs the
check covers. At -O0 clang passes bpf_map_update_elem the result of
`load ptr, ptr <prev's slot>`, in both copy() and rebind().
The old expected pattern only asked for some load of prev, and `if prev`
already does one, so it matched the buggy IR too. The check now requires
the value loaded from prev's slot to be the helper's value argument. It
fails on the code before dde720f and passes on this branch.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
retype, helper_cond, direct_assign and globals had no xfail entry and have
been passing at every level; their NOTE headers describe limits that have
since been lifted, so they are rewritten. xdp_pass was an xfail only because
it used the old count().lookup() spelling of a map call; in the current
syntax it compiles.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
handle_expr lowered a statement only when it was a call, and dropped any
other expression with an INFO log. So `print(a) if c else print(b)` compiled
to nothing at all, and failing_tests/conditionals/oneline.py passed. An
expression statement that contains a call is now a compile error; one
without (a docstring, a bare name) is still dropped. oneline.py becomes an
IR-level xfail.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`if dat:` on a local struct built Constant(struct_type, 0) in
convert_to_bool, and llvmlite failed later, while printing the module, with
"'int' object is not iterable". A struct has no truth value (C rejects
`if (s)`; Python would call any object true), so it is now a TypeError
that says to test a field. A pointer to a struct is unaffected.
The xfail was named struct_ptr but tests a struct value; it is renamed to
struct_value.py and becomes a negative test.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A local bound to a map lookup holds a pointer, and get_or_create_ptr_from_arg
handed a helper the address of that local's stack slot instead. So
count.update(k, prev) stored the kernel address of the map value, not the
value, and after prev = prev + 1 it stored the address of the temporary.
The verifier accepts both when loading as root, so nothing failed: the
failing_tests/vmlinux/named_arg.py example has been passing all along while
storing the wrong thing. The slot is now loaded when it holds a pointer.
named_arg.py moves to passing_tests, and both it and a new
map_update_from_lookup.py are pinned by IR assertions.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Without a LICENSE, @llvm.compiler.used still named one, and opt stopped on
"use of undefined value @LICENSE". A program with no LICENSE now gets "GPL",
the kernel's own license, and a warning that says so; an explicit LICENSE
is emitted as written.
The old failing license test becomes passing_tests/license_default.py: it
calls print, which lowers to the GPL-only bpf_trace_printk, so the verifier
accepts it only if the default reaches the kernel. license_non_gpl.py is
the counterpart, a verifier-level negative fixture pinned to the kernel's
GPL rejection, and test_license_ir.py checks both license sections and the
warning.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
-d asks the kernel for the instruction-level verifier log on every load. For
loop1, which makes the verifier walk nested loops, that log outgrows libbpf's
buffer; the kernel fails the load with ENOSPC, libbpf doubles the buffer and
verifies again, and on CI the load ran past the 30s timeout. A rejection
still comes with its log without -d, since libbpf retries a failed load at
log level 1 and prints it as a warning.
The timeout path also returned a bare string where callers expect stdout and
stderr, so a timeout surfaced as an AttributeError instead of the timeout.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Four programs from prog_tests/bpf_verif_scale.c that loops alone kept out.
The loop lowering matches clang's for the same C, but volatile, barrier()
and the no-unroll pragma have no spelling here: loop2 folds to a constant
and loop4 unrolls, so those two no longer make the verifier walk a loop.
Their headers and PORTING-NOTES.md say so.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* Core: Lower annotated assignment (x: c_int32 = 0)
The annotation types the slot, so `x: c_int32 = 0` is an i32 where the
literal alone would give an i64; the store goes through the same
handle_variable_assignment plain assignment uses. A bare `x: T` makes the
slot and binds nothing.
The already-bound and global-shadowing bookkeeping that Assign allocation did
inline moves into _bind_name, which both statements now call.
* Tests: Annotated assignment passes now
* Core: Lower if-branches in the function's return type
handle_if processed its branches without passing ret_type down, so a
return inside an if fell back to process_stmt's i64 default: a -> c_int32
function got `ret i64 7`, which llc rejects. The branches now go through
process_block, which threads ret_type and stops at a statement that ends
the block instead of emitting after its terminator.
* Core: Lower for-over-range and while loops, with break and continue
`for i in range(...)` steps a hidden induction counter, allocated in the
entry block next to the loop variable, and copies it into the variable each
iteration, so rebinding the variable in the body leaves the trip count alone
as in Python (and the loop stays visibly bounded for the verifier). The
counter is 64-bit, signed unless the bounds make C's arithmetic unsigned.
Bounds are evaluated once, before the loop; the step must be a nonzero
integer literal, because its sign picks the loop test.
`while` re-evaluates its test at the top of each iteration. `break` and
`continue` branch through a loop-target stack on the compilation context;
outside a loop they are a SyntaxError, as in Python. A loop's else-branch
runs on normal exit only. Anything but range() as the iterable is rejected
with NotImplementedError.
The allocation pass now descends into loop bodies and counts helper temps in
loop headers. Checked against clang -O2 on tests/c-form/loops.bpf.c: the
constant-bound cases fold to the same ret, and a helper-bounded loop gets the
same rotated loop.
* Tests: Loops pass now, plus the cases the lowering promises
- passing_tests/loops/: the seven range/while/break/continue/nested tests
move over from failing_tests/, joined by rebinding the loop variable, a
negative step, loop else-branches, and a helper-bounded loop over a
@bpfglobal that survives -O2 as a real loop for the verifier.
- failing_tests/loops/: break outside a loop, and a non-literal range step.
- for_map_items stays xfail: map iteration needs its own design.
- c-form/loops.bpf.c: the clang reference the lowering was checked against.
* Tests: Indent the loop C reference with spaces
The remove-tabs pre-commit hook rejects tab indentation outside docs/ and
Makefiles, which failed the Format job.
* Core: Fix loop edge cases the lowering got wrong
- `pass` is accepted as a statement, the natural body of a loop run for its
side effects.
- Falling off the end of a function returns 0 in the function's own return
type. After `while True` that block is unreachable, but a c_int32 function
still emitted `ret i64 0`, which llc rejected.
- A range() step other than 1 could wrap the counter past INT64_MAX or
UINT64_MAX back inside the range and loop forever. The step block now ends
the loop when the distance left to stop, exact as an unsigned number, is
no longer than the step. That is a normal exit, so the else-branch runs.
Steps of 1 cannot overshoot and keep the plain loop, so the helper-bounded
loop the verifier walks is unchanged.
- A step of 2**64 or more no longer truncates to 0: it is a compile error,
since it does not fit the counter. Steps from 2**63 up are emitted by
their bits.
- The counter's signedness folds each bound into a signed 64-bit type rather
than joining the bounds alone, so only a c_uint64 bound makes it unsigned:
range(-1, n) over a c_uint32 n runs 4 times, as in C with an __s64 counter.
* Tests: Run loop programs on the host, plus adversarial loop cases
Levels 1 and 2 only prove a loop compiles; one can still run the wrong
number of times, or forever. test_loops_run.py JIT-compiles each
helper-free passing_tests/loops case on the host (framework/host_jit.py,
in a subprocess with a timeout) and checks its return value against what
CPython returns for the same body.
- passing_tests/loops/: pass bodies, `while True` exited by a return in a
c_int32 function, step overflow past INT64_MAX, INT64_MIN and UINT64_MAX,
a c_uint32 stop with a negative start, and loop variables that must stay
one local (a nested same-name loop, a read after the loop).
- failing_tests/loops/range_step_too_wide.py: a 2**64 step is a compile error.
- reuse_loop_var_signedness.py is xfail in test_loops_run.py: every local
gets one slot typed by its first binding, so a second loop's `i` inherits
the first loop's unsigned type. `x = n_u64; x = -3` does the same, so the
fix is general, not loop-specific.
ctx_field_into_slots.py stores 8-, 32- and 64-bit sk_buff fields into
locals declared at every width and into struct fields of every width,
with IR assertions on the slot widths and the truncation before each
store. It is the compact form of a 52-case matrix (four field widths,
nine local and four struct-field destinations) compiled on master and
here: every case compiles, nothing sign-extends a field on the way in,
and where master compiled the IR is identical except where master put a
narrow local in a 64-bit slot. c_bool.py covers the local, struct field,
map value and global.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
helpers.py defined all five and return_utils mapped them, but only
XDP_DROP and XDP_PASS were exported, so the xdp_tx port had to import
XDP_TX from vmlinux and live under vmlinux/, skipped on any host without
a generated module. It imports from pythonbpf.helper and lives under
xdp/ now, returning XDP_TX bare like its siblings and the C original,
which is the shape the return fast path resolves without vmlinux.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every xfail is strict with raises=Exception, so a verifier-level
negative fixture counted any rejection as the expected one, including
one caused by a codegen regression, or by bpftool failing. A verifier
entry may now carry match = "..."; the harness attaches it as a
verifier_match marker and test_kernel_verifier fails, through
pytest.fail (not swallowed by raises=Exception), when the program is
rejected for any other reason. xdp_devmap_helpers pins its documented
"invalid bpf_context access".
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
process_array_map was a stub raising NotImplementedError while ArrayMap
was exported from pythonbpf.maps as if usable. The lowering is the hash
map's with a different type constant: the same lookup/update/delete
helpers, and the kernel fixes the key at a 4-byte index. The lookup
allocation path accepts ARRAY alongside HASH, the audit tool lists
ARRAY as supported, and the array_map_lookup_update case is a passing
test now instead of a strict xfail.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
_allocate_for_call recognised only c_int32, c_int64, c_uint32, c_uint64
and c_void_p, so queue = c_uint16(0) fell through to an i64 slot and a
later store of a u32 field into it never narrowed. Any integer ctypes
constructor now declares a slot of its width, which is what the
ctx_field_narrow_store test claimed to pin; the IR assertion pins it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
except Exception turned every import-time defect in the generated module
into a skip of every vmlinux test, so CI could pass with no vmlinux
coverage. ImportError (no module) skips; anything else propagates.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
veristat_foo (three socket programs) is clean. test_perf_link,
test_enable_stats and test_cgroup_link count with __sync_fetch_and_add, which
becomes a plain `x += 1` tagged WORKAROUND(atomics) for a mechanical sweep
once atomics exist. connect4_dropper compares against bpf_htons(port), written
out as shifts on the low 16 bits. All five pass at IR, llc and verifier level,
and bring perf_event, raw_tracepoint/sys_enter, cgroup_skb/egress and
cgroup/connect4 under test.
The porting notes gain the third batch, the atomics tag, the current blocker
histogram from the checked-in audit tool, and how to re-run it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLMW3X7opqAPH6bjmTVkr7
Every program on the selftest audit's Tier 1 and Tier 2 lists that the compiler
can express today: xdp_dummy, priv_prog, test_xdp_link, xdp_tx, tc_dummy,
test_tc_bpf, cgroup_mprog, cgroup_skb_direct_packet_access, test_signed_loader,
test_signed_loader_data, test_netfilter_link_attach, kprobe_multi_empty,
uprobe_multi_bench, uprobe_multi_usdt, test_link_pinning and
test_xdp_devmap_helpers. Fifteen pass at every level, bringing tc, tcx,
cgroup/getsockopt, cgroup_skb, socket, netfilter, kprobe.multi, uprobe.multi,
usdt and tp_btf program types under test for the first time.
test_xdp_devmap_helpers is a negative fixture upstream: reading egress_ifindex
is only legal with expected_attach_type = BPF_XDP_DEVMAP and the driver asserts
the plain load fails. It is a strict verifier-level xfail here for the same
reason, until expected_attach_type can be expressed.
The porting notes record the batch and why each remaining program on the two
lists is still out of reach.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLMW3X7opqAPH6bjmTVkr7
A sub-register context field is loaded zero-extended to i64, and the
assignment path accepted it only into a 64-bit slot or one whose type was
exactly the field's declared type. The second case never worked in practice:
`data_end = skb.data_end` into a c_uint32 global died in llvmlite with
"cannot store i64 to i32*" because the value was still i64.
Route the store through convert(), sizing from the physical value and signing
from the field, like every other integer store since the signedness work: a
no-op into an i64 slot, a trunc into anything narrower. Found by porting
cgroup_skb_direct_packet_access.c, which is that exact statement.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLMW3X7opqAPH6bjmTVkr7
The selftest spike substituted a one-entry HashMap for every upstream global
because PythonBPF had no global variable support. Integer-scalar @bpfglobal
support has since landed, so the three affected ports now declare the upstream
globals directly: get_cgroup_id reads expected_pid and writes cg_id, autoattach
shares prog1_called/prog2_called between two programs, and perf_skip reads ip.
perf_skip stays a strict xfail on the nested ctx.regs.ip access.
Update the tests README and porting notes accordingly; the WORKAROUND tag no
longer exists in the tree.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLMW3X7opqAPH6bjmTVkr7
xdp_md.data is a u32 in C, but the verifier tracks it as a packet
pointer and rejects 32-bit arithmetic on it: "R0 32-bit pointer
arithmetic prohibited", the same for a C program, which is why C casts
it through (void *)(long) first. The u32 ranking the test pins is the
correct one; it just has to be pinned on a field that is a scalar to the
verifier too. ingress_ifindex is.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
One IR-shape case per fix: u32 >>= / //= / %= emit lshr/udiv/urem;
ktime() >> 1 and pid() // 3 emit lshr/udiv; p >> 63 on a c_uint64 map
value is lshr; ctx.data - c_int32 is a u32 subtraction with the
trunc/zext pair rather than a 64-bit one.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- process_stmt now raises NotImplementedError on an unsupported statement
instead of warning: a dropped statement silently changes what the
program means (a for/while loop compiled to nothing).
- failing_tests/loops/: 8 xfail tests for for/while/break/continue/nested
loops and map iteration
- failing_tests/assign/annotated_assign.py: xfail for `x: c_int64 = 0`
(ast.AnnAssign is not handled)
return/map_value.py is the C shape `if (p) return *p;`; return_struct.py
is the type error convert() now raises; vmlinux/enum_rank.py pins the
u32 trunc/zext pair for `XDP_PASS - k`. test_signedness_ir.py takes
paths under passing_tests so it can assert on all three, and skips the
vmlinux case when vmlinux.py is not importable, as the harness does.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
failing_tests/vmlinux/assignment_handling.py pinned exactly this gap
("This gives an error, but / this does not"); it moves to the passing
suite and its xfail entry goes. enum_to_local.py adds the C shape
`int act = XDP_PASS; if (...) act = XDP_DROP; return act;`.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every read of a bare name resolves local, then BPF global, then vmlinux
enum constant, except the allocation pass's variable-to-variable path,
which stopped after the globals and rejected `act = XDP_PASS` with
"source variable not found", while `act = XDP_PASS + 0` compiled through
the binop path. The error text pointed the wrong way: it is the target
that needs a stack slot, and the pass could not type it. An enum
constant is an immediate with no storage of its own, so the target gets
the i64 slot a literal gets, and the constant is folded at the store.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Seven programs under passing_tests/signedness, one per case in
tests/c-form/signedness.bpf.c: unsigned and signed widening, mixed
division and remainder, unsigned comparison, u32 * u32 wrapping before
the widening, right shifts, and literal rank. Levels 1 and 2 compile
them like any other case; test_signedness_ir.py asserts the shape of the
IR against what clang emits for the C (zext vs sext, udiv vs sdiv,
icmp ugt vs sgt, lshr vs ashr, the trunc/zext pair around the wrap).
The XDP xfail note no longer claims the guard is a signed compare.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU
Eight cases, each reading operands from .bss globals (so clang cannot fold)
and writing its result to a .bss global (so the runtime proof is a bpftool
map dump). The IR clang emits is the specification for the signedness work:
s64 = u32 zext i32 -> i64 (widening is source-driven)
u64 = s32 sext i32 -> i64
u32 / s32 udiv i32 (usual arithmetic conversions)
u64 > s64 icmp ugt i64
u32 * u32 -> u64 mul i32, then zext (wraps at 32 before widening)
u32 >> 4 lshr i32
s32 >> 4 ashr i32
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU
Levels 1 and 2 only prove the globals cases compile; what they are about
is whether a name resolves to the @bpfglobal symbol or to a stack slot
that shadows it. test_globals_ir.py reads the IR of each BPF function
and counts loads and stores per operand, exactly: `global counter` is
load/add/store on @counter with no slot, a read needs no declaration and
hits the symbol, and a write without `global` binds a slot for the whole
body of that function while a second function still reads the symbol.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
globals_shadowing.py asserted the old rule, so it moves to
passing_tests/globals/shadowing.py and asserts the new one: the write
without `global` binds a local, and a second program still reads the
global's initializer. copy_to_local.py covers `x = a_global`, the read
shape that used to fail in the allocation pass.
globals_read_before_shadow.py takes over as the failing case, since a
read above the binding is what Python rejects, and the augassign test
keeps its xfail with the reason reworded to the UnboundLocalError it is.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Assigning a global's name without declaring it `global` was a compile
error. Python makes it a local instead: the name is local for the whole
function body, the global keeps its value, and only a `global` statement
writes through to it. Do that, so the same program means the same thing
in Python and in BPF.
Python's scoping is function-wide and static, which the compiler gets
for free: allocation runs as a pre-pass over the whole body, so a name
bound anywhere is in local_sym_tab before the first statement is
lowered, and reads resolve local-first. What does not come for free is
the read above the binding, which Python answers with UnboundLocalError
rather than the global's value. There is no runtime here in which to
raise that, so the local records where its binding ends and a read above
it is rejected, with the message Python would have given. Silence there
would load an uninitialised stack slot through a name the author
expected to be the global.
`counter += 1` without `global counter` stays an error for the same
reason: it binds a local and reads it in the same statement. Only its
message changes, from a shadowing refusal to the UnboundLocalError it
actually is.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reads resolve a name local-first (_handle_name_expr, get_operand_value, the
printk formatter), but both write paths checked the declared-global set
before local_sym_tab. Normally harmless because the two tables are disjoint
by construction -- except for a parameter whose name matches a @bpfglobal.
With 'global ctx' in a function taking ctx, the write path stored to the
global while a read of the same name picked the parameter and crashed on its
None slot: the same name resolving to different storage depending on which
side of an assignment it sat.
Python forbids the construct outright, and now so does the compiler, with
Python's own wording: SyntaxError: name 'ctx' is parameter and global. Both
write paths now resolve local-first like the reads, so all name lookups read
the same way; and an augmented assignment to the context parameter itself
gets a clear error instead of a store to None.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU
A struct-field test with a non-add operator and a sub-64-bit field (the
narrow-on-store path), and a strict expected failure for counter += 1 without
a global statement, which now fails as loudly as plain assignment does. Ruff
flags that line as F823 (referenced before assignment) -- the same
UnboundLocalError Python itself would raise, which is exactly the semantics
the global statement requirement mirrors.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1PX8EuP9C3o3veWGA84RF
Two tests locking the shadowing semantics: a local named XDP_PASS returned
from a program (the exact case the return fast path used to hijack), and a
vmlinux-importing program where a local shadows one enum constant while a
@bpfglobal shadows another, read in expressions and f-strings.
The vmlinux test needs noqa on its import and both collision sites: ruff
rightly flags unused imports and redefinitions in normal Python, and this file
is deliberately made of them.
These pin compilation; the value-level proof (ret of 55, not 2) was verified
against the emitted IR and the clang reference for the same collision shapes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1PX8EuP9C3o3veWGA84RF
Five passing tests: read in condition and print; the get_cgroup_id_kern.c
read-one-write-one shape; the counter += 1 idiom; two programs sharing global
state (the test_autoattach.c shape); and mixed .bss/.data placement with mixed
widths and signedness.
Three strict expected failures documenting deliberate errors: assignment
without the global statement (shadowing), a global statement naming a
non-global, and a non-integer global type.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1PX8EuP9C3o3veWGA84RF
Captures the development loop this project has always used for new compiler
features: write a minimal C eBPF program exercising only the feature, compile
it to LLVM IR and read that as the specification, diff against what PythonBPF
currently emits, stop for a human decision on the Python syntax, implement
against the reference, and test at the right tier. Recorded as a project skill
so agents follow it too; the syntax step is an explicit hard stop.
tests/c-form/global_vars.bpf.c is the loop's step 1 for global variables: the
four C global classes and nothing else. Its IR established that every global is
an independent symbol accessed by plain load/store, that llc manufactures the
BTF VAR/DATASEC entries from DIGlobalVariable metadata, and that clang folds
const but not const volatile -- the facts the globals design rests on.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1PX8EuP9C3o3veWGA84RF
The four ports were the experiment; this is the result. Covers whether
LLM-assisted porting is worth continuing (yes, in feature-sized increments), what
a passing port actually proves (a compiler assertion, not a behavioural one), and
the four distinct global-variable shapes the spike turned up.
Includes the finding that libbpf implements globals as single-element
BPF_MAP_TYPE_ARRAY maps, so a one-element ArrayMap -- not a HashMap -- is the
structurally faithful stand-in, and that the ELF half of global support already
works today via the machinery behind @bpfglobal.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Ported faithfully from test_perf_skip.c, which reads the sampled instruction
pointer out of a perf_event context: ctx.regs.ip. That is two levels of struct
field access and PythonBPF supports one, so this lands as a strict expected
failure describing the gap.
_allocate_for_attribute in allocation_pass.py declines to allocate unless the
attribute's base is a plain Name, so the nested form is skipped. One level on
the same context works today -- ctx.sample_period compiles and llc's fine.
Worth noting for whoever picks this up: the failure surfaces as
'SyntaxError: Undefined variable actual', naming the assignment target rather
than the nested access responsible. The allocation pass declines quietly and the
expression pass then trips over the missing symbol.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Ports of programs from tools/testing/selftests/bpf/progs/ in the Linux tree,
each naming its upstream original in a header comment.
tracing/tracepoint_sched_switch.py test_tracepoint.c
tracing/get_cgroup_id.py get_cgroup_id_kern.c
tracing/autoattach.py test_autoattach.c
Deliberately a small spike rather than bulk coverage. The three sample different
global-variable shapes, since substituting for globals is what porting the rest
of the corpus will mostly consist of: none at all (the control case), a scalar
read plus a scalar write, and two flags written from two programs on two
different attach points.
They also widen the range of program types under test.
tracepoint/sched/sched_switch and raw_tp/sys_enter were previously unexercised;
@section writes its string straight into the ELF with no allowlist, so that
pass-through had only ever been tested against a handful of types.
Only the BPF half of each selftest is ported -- upstream pairs every program
with a userspace driver in prog_tests/ that loads and asserts, whereas this
framework compiles and verifies but never runs. tests/README.md now says so
explicitly, along with the WORKAROUND(globals) convention marking each map
substituted for a global.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Ports that import from vmlinux need the same treatment as
tests/passing_tests/vmlinux/ -- skipped, not failed, when no vmlinux.py has been
generated for the running kernel. Without this they fail outright wherever one
is absent, CI included.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>