mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +00:00
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)'.
This commit is contained in:
19
Makefile
19
Makefile
@ -6,18 +6,29 @@ clean:
|
||||
rm -rf examples/*.ll examples/*.o
|
||||
rm -rf htmlcov .coverage
|
||||
|
||||
test:
|
||||
# Regenerate the master vmlinux.py from the running kernel's BTF, then
|
||||
# symlink it into every directory under tests/ so both pytest (which
|
||||
# resolves "import vmlinux" via pythonpath=["."]) and any test file run
|
||||
# standalone from its own directory see the same, always-fresh fixture.
|
||||
vmlinux:
|
||||
python3 tools/vmlinux-gen.py -o vmlinux.py
|
||||
@find tests -type d -not -path '*/__pycache__*' | while read -r d; do \
|
||||
target=$$(python3 -c "import os,sys; print(os.path.relpath('vmlinux.py', sys.argv[1]))" "$$d"); \
|
||||
ln -sf "$$target" "$$d/vmlinux.py"; \
|
||||
done
|
||||
|
||||
test: vmlinux
|
||||
pytest tests/ -W ignore::DeprecationWarning -v --tb=short -m "not verifier"
|
||||
|
||||
test-cov:
|
||||
test-cov: vmlinux
|
||||
pytest tests/ -W ignore::DeprecationWarning -v --tb=short -m "not verifier" \
|
||||
--cov=pythonbpf --cov-report=term-missing --cov-report=html
|
||||
|
||||
test-verifier:
|
||||
test-verifier: vmlinux
|
||||
@echo "NOTE: verifier tests shell out to 'sudo bpftool'; run 'sudo -v' first so"
|
||||
@echo " the timestamp does not lapse mid-run. bpftool must be installed."
|
||||
pytest tests/test_verifier.py -W ignore::DeprecationWarning -v --tb=short -m verifier
|
||||
|
||||
all: clean install
|
||||
|
||||
.PHONY: all clean install test test-cov test-verifier
|
||||
.PHONY: all clean install test test-cov test-verifier vmlinux
|
||||
|
||||
@ -403,7 +403,7 @@ def process_bpf_chunk(func_node, compilation_context, return_type):
|
||||
if func_node.args.args:
|
||||
# Only look at the first argument for now
|
||||
param = func.args[0]
|
||||
param.add_attribute("nocapture")
|
||||
param.add_attribute("captures(none)")
|
||||
|
||||
probe_string = get_probe_string(func_node)
|
||||
if probe_string is not None:
|
||||
|
||||
@ -35,6 +35,10 @@ def collect_all_test_files() -> list[BpfTestCase]:
|
||||
cases = []
|
||||
for subdir in ("passing_tests", "failing_tests"):
|
||||
for py_file in sorted((TESTS_DIR / subdir).rglob("*.py")):
|
||||
if py_file.name == "vmlinux.py":
|
||||
# Not a test case: the per-directory symlink to the master
|
||||
# vmlinux fixture module, kept alongside tests that import it.
|
||||
continue
|
||||
rel = str(py_file.relative_to(TESTS_DIR))
|
||||
needs_vmlinux = _is_vmlinux_test(rel)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user