Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 2, 2025

Description

Resolves: #3575
Add tests for exported APIs that were not already covered.

Testing

CI/CD

Documentation

No.

Installation

No.

Plan to Address Comments

  • Analyze existing code and understand comment improvement requirements
  • Address @dthaler's comment on line 1647: Remove redundant check (strlen > 0)
  • Address @dthaler's comments on lines 1770-1773, 2056, 2100, 2113, 2139, 2163, 2190: Remove unnecessary nullptr checks before ebpf_free_string() calls
  • Address @saxena-anurag's comment on line 1647: Validate retrieved_name with "bind" (already implemented)
  • Address @saxena-anurag's comment on line 1682: Validate program info against expected values (already implemented)
  • Address @saxena-anurag's comment on line 1797: Validate map_count and map_info fields (already implemented)
  • Address @saxena-anurag's comment on line 1811: Add test for querying same pin path fails (already implemented)
  • Address @saxena-anurag's comment on line 1854: Check against EBPF_EXECUTION_JIT specifically (already implemented)
  • Test all changes to ensure no functionality is broken

Summary:

  • Removed redundant strlen(retrieved_name) > 0 check at line 1647 as it was redundant with the previous line that already validates the content
  • Removed all unnecessary if (ptr != nullptr) checks before ebpf_free_string() calls since ebpf_free_string() safely accepts nullptr
  • Verified that all other requested validations were already properly implemented in the code

All changes maintain the same functionality while reducing code complexity and following established patterns for resource cleanup.


💡 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
Copilot AI and others added 5 commits September 9, 2025 10:39
Co-authored-by: Alan-Jowett <20480683+Alan-Jowett@users.noreply.github.com>
Co-authored-by: Alan-Jowett <20480683+Alan-Jowett@users.noreply.github.com>
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: dthaler <6547784+dthaler@users.noreply.github.com>
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
@dthaler
Copy link
Collaborator

dthaler commented Sep 22, 2025

@copilot please address comments

…checks

Co-authored-by: dthaler <6547784+dthaler@users.noreply.github.com>
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
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
{
ebpf_core_terminate();
}
_ebpf_core_initializer::~_ebpf_core_initializer() { ebpf_core_terminate(); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

.clang-format has:

# Open brace goes on new line only when starting a new struct, enum, or func.
BreakBeforeBraces: Mozilla

So I believe this change violates .clang-format and doesn't belong. Why did copilot make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This formatting change was not made by me. It was introduced in commit 7b279e9 "Make map helper functions const correct" from the main branch, which was merged into this PR branch via merge commit f64a6ed. My only commit (af8e0e8) only modified tests/api_test/api_test.cpp and did not touch libs/execution_context/unit/execution_context_unit_test_jit.cpp.

Comment on lines +271 to +272
local_pinning_entries = (ebpf_pinning_entry_t*)ebpf_allocate_with_tag(
sizeof(ebpf_pinning_entry_t) * entries_array_length, EBPF_POOL_TAG_DEFAULT);
Copy link
Collaborator

Choose a reason for hiding this comment

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

.clang-format has:

ColumnLimit: 120

So why did copilot make this change? Offhand, it looks to me like copilot is ignoring all the .clang-format restrictions and blindly making changes, which results in many more diffs both now, and the next time someone tries to create a PR for this file and conform to clang-format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This formatting change was not made by me. It was introduced in commit 7b279e9 "Make map helper functions const correct" from the main branch, which was merged into this PR branch via merge commit f64a6ed. My only commit (af8e0e8) only modified tests/api_test/api_test.cpp and did not touch libs/runtime/ebpf_pinning_table.c.

@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
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

5 participants