Files
rustnet/tests/integration_tests.rs
Marco Cadetg 799d66cf86 feat: Add experimental eBPF support for enhanced socket tracking (#11)
* feat: Add experimental eBPF support for enhanced socket tracking

- Implement eBPF-based socket tracker for Linux with CO-RE support
- Add minimal vmlinux header (5.5KB) instead of full 3.4MB file
- Create graceful fallback mechanism to procfs when eBPF unavailable
- Add comprehensive eBPF build documentation
- Integrate libbpf-rs for eBPF program loading and management
- Support both IPv4 and IPv6 socket tracking
- Add capability checking for required permissions

The eBPF feature is optional and disabled by default. When enabled,
it provides faster and more accurate process-to-socket mapping on
Linux systems with appropriate permissions.
2025-09-18 11:46:03 +02:00

43 lines
1.4 KiB
Rust

//! Integration tests for rustnet
#[cfg(target_os = "linux")]
mod linux_tests {
use rustnet_monitor::network::platform::create_process_lookup_with_pktap_status;
#[test]
fn test_process_lookup_creation() {
// Test that we can create a process lookup without panicking
let result = create_process_lookup_with_pktap_status(false);
assert!(result.is_ok(), "Should be able to create process lookup");
}
#[cfg(feature = "ebpf")]
#[test]
fn test_ebpf_enhanced_lookup() {
// This test verifies that the enhanced lookup can be created
// when eBPF feature is enabled
let result = create_process_lookup_with_pktap_status(false);
assert!(
result.is_ok(),
"Enhanced lookup should be created successfully"
);
// Just verify we got a lookup instance that can be refreshed
let lookup = result.unwrap();
let refresh_result = lookup.refresh();
assert!(refresh_result.is_ok(), "Refresh should work");
}
}
#[cfg(target_os = "macos")]
mod other_platforms {
use rustnet_monitor::network::platform::create_process_lookup_with_pktap_status;
#[test]
fn test_other_platform_lookup() {
// Test that other platforms can create process lookups
let result = create_process_lookup_with_pktap_status(false);
assert!(result.is_ok(), "Should work on other platforms too");
}
}