Skip to content

Commit 559d057

Browse files
regenerate and symlink a single master vmlinux.py for make test
- make test/test-cov/test-verifier now depend on a 'vmlinux' target that regenerates vmlinux.py from the running kernel's BTF and symlinks it into every directory under tests/, replacing the stale, duplicated vmlinux.py fixtures that used to be committed there. - collector.py now skips the 'vmlinux.py' filename when collecting BPF test cases, since it's a fixture module, not a test program - it was previously being mis-collected and compiled as a bogus test. - functions_pass.py: llvmlite >=0.49 renamed the 'nocapture' argument attribute to 'captures(none)'.
1 parent 7b704cb commit 559d057

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,29 @@ clean:
66
rm -rf examples/*.ll examples/*.o
77
rm -rf htmlcov .coverage
88

9-
test:
9+
# Regenerate the master vmlinux.py from the running kernel's BTF, then
10+
# symlink it into every directory under tests/ so both pytest (which
11+
# resolves "import vmlinux" via pythonpath=["."]) and any test file run
12+
# standalone from its own directory see the same, always-fresh fixture.
13+
vmlinux:
14+
python3 tools/vmlinux-gen.py -o vmlinux.py
15+
@find tests -type d -not -path '*/__pycache__*' | while read -r d; do \
16+
target=$$(python3 -c "import os,sys; print(os.path.relpath('vmlinux.py', sys.argv[1]))" "$$d"); \
17+
ln -sf "$$target" "$$d/vmlinux.py"; \
18+
done
19+
20+
test: vmlinux
1021
pytest tests/ -W ignore::DeprecationWarning -v --tb=short -m "not verifier"
1122

12-
test-cov:
23+
test-cov: vmlinux
1324
pytest tests/ -W ignore::DeprecationWarning -v --tb=short -m "not verifier" \
1425
--cov=pythonbpf --cov-report=term-missing --cov-report=html
1526

16-
test-verifier:
27+
test-verifier: vmlinux
1728
@echo "NOTE: verifier tests shell out to 'sudo bpftool'; run 'sudo -v' first so"
1829
@echo " the timestamp does not lapse mid-run. bpftool must be installed."
1930
pytest tests/test_verifier.py -W ignore::DeprecationWarning -v --tb=short -m verifier
2031

2132
all: clean install
2233

23-
.PHONY: all clean install test test-cov test-verifier
34+
.PHONY: all clean install test test-cov test-verifier vmlinux

pythonbpf/functions/functions_pass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def process_bpf_chunk(func_node, compilation_context, return_type):
403403
if func_node.args.args:
404404
# Only look at the first argument for now
405405
param = func.args[0]
406-
param.add_attribute("nocapture")
406+
param.add_attribute("captures(none)")
407407

408408
probe_string = get_probe_string(func_node)
409409
if probe_string is not None:

tests/framework/collector.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def collect_all_test_files() -> list[BpfTestCase]:
3535
cases = []
3636
for subdir in ("passing_tests", "failing_tests"):
3737
for py_file in sorted((TESTS_DIR / subdir).rglob("*.py")):
38+
if py_file.name == "vmlinux.py":
39+
# Not a test case: the per-directory symlink to the master
40+
# vmlinux fixture module, kept alongside tests that import it.
41+
continue
3842
rel = str(py_file.relative_to(TESTS_DIR))
3943
needs_vmlinux = _is_vmlinux_test(rel)
4044

0 commit comments

Comments
 (0)