ebpf-verifier icon indicating copy to clipboard operation
ebpf-verifier copied to clipboard

Add EbpfTransformer Catch2 test suite

Open elazarg opened this issue 4 months ago • 2 comments

Summary

  • add helpers in the transformer test fixture to construct program info for alternate platforms and to scope map descriptor mutations
  • extend the transformer Catch2 suite with map-load/map-lookup/callx scenarios and with stack writable-argument and packet-reallocation call semantics

Testing

  • cmake --build build --target tests
  • ./tests "[transformer]"

https://chatgpt.com/codex/tasks/task_e_68c897a330288329bd41b7fed0dbb44a

Summary by CodeRabbit

  • New Features
    • No user-facing changes.
  • Tests
    • Added extensive test coverage for the eBPF transformer, spanning arithmetic, pointer/stack behavior, bitwise and shift operations, endianness, assumptions, packet and map interactions, subprogram calls, and memory round-trips. Improves reliability and guards against regressions.
  • Chores
    • Enabled the new tests in the build pipeline.

elazarg avatar Sep 16 '25 19:09 elazarg

Walkthrough

Adds a new eBPF transformer test suite, wires it into the build when tests are enabled, and exposes internal state of EbpfDomain to tests via a forward declaration and friend class.

Changes

Cohort / File(s) Summary of edits
Build/Test wiring
CMakeLists.txt
Includes test_ebpf_transformer.cpp in the test sources within the VERIFIER_ENABLE_TESTS block.
Domain test access
src/crab/ebpf_domain.hpp
Adds forward declaration class EbpfDomainInspector; and friend class EbpfDomainInspector; inside EbpfDomain.
New eBPF transformer tests
src/test/test_ebpf_transformer.cpp
Introduces comprehensive tests covering arithmetic, bitwise, shifts, pointer/stack semantics, endianness, assumptions, packets, maps (incl. maps of maps, program arrays), calls/subprograms, and helper dispatch, along with test utilities and inspectors.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add EbpfTransformer Catch2 test suite" succinctly and accurately summarizes the PR's primary change: adding a Catch2-based test suite for the eBPF transformer and integrating it into the build. It is specific to the main intent and avoids unnecessary detail such as file lists or internal implementation. A reviewer scanning project history will understand the PR focus from this title.
✨ Finishing touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch codex/add-catch2-test-suite-for-ebpftransformer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Sep 16 '25 19:09 coderabbitai[bot]

Pull Request Test Coverage Report for Build 17776994019

Details

  • 545 of 545 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on codex/add-catch2-test-suite-for-ebpftransformer at 88.796%

Totals Coverage Status
Change from base Build 17748859600: 88.8%
Covered Lines: 9114
Relevant Lines: 10264

💛 - Coveralls

coveralls avatar Sep 16 '25 20:09 coveralls