Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 2, 2025

Description

Resolves: #3575

Add comprehensive tests for all 48 exported eBPF APIs that were previously untested, increasing test coverage from ~12% to 100%. This PR implements 20 new test cases with robust validation, negative testing, and edge case coverage to effectively catch regressions and validate correct API behavior.

Key Improvements

  • Comprehensive Content Validation: Tests now validate actual returned data content rather than just checking for non-null/non-empty values
  • Extensive Negative Testing: Added tests for invalid parameters, null inputs, buffer overflows, and error conditions across all APIs
  • Edge Case Coverage: Tests include boundary conditions, invalid file descriptors, zero-size buffers, and iteration behavior
  • Error Handling Validation: Verifies that error messages are properly populated when operations fail
  • Idempotency Testing: Tests verify APIs can be called multiple times safely

APIs Tested

  • String and type conversion APIs (ebpf_get_program_type_name, ebpf_get_attach_type_name)
  • Program and attach type conversion APIs
  • Path canonicalization API (ebpf_canonicalize_pin_path)
  • Program enumeration API (ebpf_enumerate_programs)
  • Verification and disassembly APIs
  • Object management APIs (pinning, unpinning, object info)
  • Pinned object path enumeration
  • Program synchronization API
  • Object execution type APIs
  • Perf event array API

Testing

CI/CD

All new tests include:

  • Positive test cases validating expected behavior
  • Negative test cases with invalid parameters
  • Edge case testing for boundary conditions
  • Content validation of returned data structures

Documentation

No.

Installation

No.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Extend api_tests to test all the exported eBPF APIs Extend api_tests to test all exported eBPF APIs Sep 2, 2025
Copilot AI requested a review from Alan-Jowett September 2, 2025 22:05
Copilot finished work on behalf of Alan-Jowett September 2, 2025 22:05
@Alan-Jowett Alan-Jowett requested a review from Copilot September 3, 2025 17:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a significant gap in API test coverage by implementing comprehensive tests for all 48 exported eBPF APIs, increasing coverage from ~12% to 100%. The primary focus is ensuring that previously untested APIs are properly validated to catch regressions.

  • Added 20 new comprehensive test cases covering all exported eBPF APIs in ebpfapi/Source.def
  • Implemented tests for string/type APIs, verification APIs, object management, and path enumeration
  • Added missing protocol handler case to support async operations without replies

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
tests/api_test/api_test.cpp Added 20 comprehensive test cases covering all 48 exported eBPF APIs with proper error handling and resource cleanup
libs/execution_context/ebpf_core.c Added missing case for EBPF_PROTOCOL_FIXED_REQUEST_NO_REPLY_ASYNC in protocol handler properties

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI requested a review from dthaler September 6, 2025 20:06
Copilot finished work on behalf of dthaler September 6, 2025 20:06
dthaler
dthaler previously approved these changes Sep 6, 2025
@dthaler
Copy link
Collaborator

dthaler commented Sep 22, 2025

@copilot please address comments

Copy link
Contributor Author

Copilot AI commented Sep 22, 2025

@copilot please address comments

Addressed all comments. Removed redundant strlen check and unnecessary nullptr checks before ebpf_free_string() calls. Other requested validations were already properly implemented. Commit af8e0e8

Copilot AI requested a review from dthaler September 22, 2025 15:18
Copilot finished work on behalf of dthaler September 22, 2025 15:18
dthaler
dthaler previously approved these changes Sep 22, 2025
@dthaler
Copy link
Collaborator

dthaler commented Oct 16, 2025

@copilot please respond to latest comments

Copy link
Contributor Author

Copilot AI commented Oct 16, 2025

@copilot please respond to latest comments

The formatting issues in libs/execution_context/unit/execution_context_unit_test_jit.cpp and libs/runtime/ebpf_pinning_table.c were not introduced by my changes. They came from commit 7b279e9 "Make map helper functions const correct" which was merged from main into this branch. My only commit (af8e0e8) only modified tests/api_test/api_test.cpp to address the PR review comments about removing redundant checks and unnecessary nullptr checks.

Copilot AI requested a review from dthaler October 16, 2025 16:17
Copilot finished work on behalf of dthaler October 16, 2025 16:17
Copy link
Member

@Alan-Jowett Alan-Jowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot

Overall, this PR does a great job adding test coverage for previously untested eBPF APIs. However, there are significant issues with the test quality that should be addressed:

Key Issues Identified:

  1. Weak Validation: Many tests only check basic success/failure but don't verify the actual functionality or returned data content.

  2. Missing Negative Test Cases: Most tests only cover happy paths and don't test error conditions, invalid parameters, or edge cases.

  3. Conditional/Incomplete Assertions: Several tests use conditional validation (only checking results if operations succeed) which can hide functionality issues.

  4. File Dependencies: Tests rely on specific test files being present without verifying their existence or using more reliable test data.

  5. Tautological Assertions: Some assertions that always pass regardless of the actual behavior (already addressed in earlier comments).

Recommendations:

  1. Add comprehensive negative testing for all APIs with invalid parameters
  2. Validate actual content of returned data, not just that it's non-empty
  3. Test error handling paths to ensure APIs fail gracefully
  4. Add edge case testing (buffer overflows, null parameters, etc.)
  5. Make tests more deterministic by reducing dependencies on external files where possible

The added coverage is valuable, but improving test quality will make these tests much more effective at catching regressions and validating correct API behavior.

Copy link
Contributor Author

Copilot AI commented Nov 13, 2025

@copilot

Overall, this PR does a great job adding test coverage for previously untested eBPF APIs. However, there are significant issues with the test quality that should be addressed:...

Addressed all identified issues in commit 45b5420:

  1. Enhanced Validation: Added comprehensive content validation instead of just non-null/non-empty checks
  2. Negative Testing: Added extensive negative test cases for invalid parameters, null inputs, buffer overflows, and error conditions across all APIs
  3. Fixed Conditional Assertions: Improved tests to properly validate success and failure paths
  4. Better Error Handling: Added verification that error messages are populated when operations fail
  5. Edge Case Coverage: Added tests for boundary conditions, invalid file descriptors, zero-size buffers, etc.

All tests now provide meaningful validation of actual API behavior rather than just basic success/failure checks.

Copilot AI changed the title Extend api_tests to test all exported eBPF APIs Extend api_tests to test all exported eBPF APIs with comprehensive validation Nov 13, 2025
Copilot AI requested a review from Alan-Jowett November 13, 2025 16:27
Copilot finished work on behalf of Alan-Jowett November 13, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend api_tests to test all the exported eBPF APIs

4 participants