diff --git a/test/integration-ebpf/src/bpf_probe_read.rs b/test/integration-ebpf/src/bpf_probe_read.rs index 5c07322f..12313974 100644 --- a/test/integration-ebpf/src/bpf_probe_read.rs +++ b/test/integration-ebpf/src/bpf_probe_read.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{ helpers::{bpf_probe_read_kernel_str_bytes, bpf_probe_read_user_str_bytes}, @@ -77,3 +77,8 @@ pub fn test_bpf_probe_read_kernel_str_bytes(ctx: ProbeContext) { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/lib.rs b/test/integration-ebpf/src/lib.rs index 3ac3e595..d7943640 100644 --- a/test/integration-ebpf/src/lib.rs +++ b/test/integration-ebpf/src/lib.rs @@ -1,3 +1,3 @@ -#![no_std] +#![cfg_attr(target_arch = "bpf", no_std)] // This file exists to enable the library target. diff --git a/test/integration-ebpf/src/log.rs b/test/integration-ebpf/src/log.rs index e7d715d6..45364c79 100644 --- a/test/integration-ebpf/src/log.rs +++ b/test/integration-ebpf/src/log.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use core::net::{IpAddr, Ipv4Addr, Ipv6Addr}; @@ -87,3 +87,8 @@ pub fn test_log(ctx: ProbeContext) { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/map_test.rs b/test/integration-ebpf/src/map_test.rs index 6119f4ad..4a2e9be5 100644 --- a/test/integration-ebpf/src/map_test.rs +++ b/test/integration-ebpf/src/map_test.rs @@ -1,8 +1,8 @@ // Socket Filter program for testing with an arbitrary program with maps. // This is mainly used in tests with consideration for old kernels. -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{ macros::{map, socket_filter}, @@ -41,3 +41,8 @@ pub fn simple_prog(_ctx: SkBuffContext) -> i64 { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/memmove_test.rs b/test/integration-ebpf/src/memmove_test.rs index 0328a241..5d185fee 100644 --- a/test/integration-ebpf/src/memmove_test.rs +++ b/test/integration-ebpf/src/memmove_test.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use core::mem; @@ -59,3 +59,8 @@ fn try_do_dnat(ctx: XdpContext) -> Result { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/name_test.rs b/test/integration-ebpf/src/name_test.rs index 0fcd85fe..25a8f906 100644 --- a/test/integration-ebpf/src/name_test.rs +++ b/test/integration-ebpf/src/name_test.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{bindings::xdp_action, macros::xdp, programs::XdpContext}; @@ -20,3 +20,8 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/pass.rs b/test/integration-ebpf/src/pass.rs index 295485eb..a2d922b4 100644 --- a/test/integration-ebpf/src/pass.rs +++ b/test/integration-ebpf/src/pass.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{bindings::xdp_action, macros::xdp, programs::XdpContext}; @@ -22,3 +22,8 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/raw_tracepoint.rs b/test/integration-ebpf/src/raw_tracepoint.rs index 160b249a..3b790c80 100644 --- a/test/integration-ebpf/src/raw_tracepoint.rs +++ b/test/integration-ebpf/src/raw_tracepoint.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{ macros::{map, raw_tracepoint}, @@ -31,3 +31,8 @@ pub fn sys_enter(ctx: RawTracePointContext) -> i32 { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/redirect.rs b/test/integration-ebpf/src/redirect.rs index 66db7980..941eb24f 100644 --- a/test/integration-ebpf/src/redirect.rs +++ b/test/integration-ebpf/src/redirect.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{ bindings::xdp_action, @@ -80,3 +80,8 @@ fn inc_hit(index: u32) { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/relocations.rs b/test/integration-ebpf/src/relocations.rs index 7783b341..b15324d5 100644 --- a/test/integration-ebpf/src/relocations.rs +++ b/test/integration-ebpf/src/relocations.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use core::hint; @@ -44,3 +44,8 @@ fn set_result_backward(index: u32, value: u64) { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/ring_buf.rs b/test/integration-ebpf/src/ring_buf.rs index 5e300ec6..4cf721fe 100644 --- a/test/integration-ebpf/src/ring_buf.rs +++ b/test/integration-ebpf/src/ring_buf.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{ macros::{map, uprobe}, @@ -51,3 +51,8 @@ pub fn ring_buf_test(ctx: ProbeContext) { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/simple_prog.rs b/test/integration-ebpf/src/simple_prog.rs index 25fb68e4..1a97033c 100644 --- a/test/integration-ebpf/src/simple_prog.rs +++ b/test/integration-ebpf/src/simple_prog.rs @@ -1,8 +1,8 @@ // Socket Filter program for testing with an arbitrary program. // This is mainly used in tests with consideration for old kernels. -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{macros::socket_filter, programs::SkBuffContext}; @@ -17,3 +17,8 @@ pub fn simple_prog(_ctx: SkBuffContext) -> i64 { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/strncmp.rs b/test/integration-ebpf/src/strncmp.rs index 398cd726..fe3b1009 100644 --- a/test/integration-ebpf/src/strncmp.rs +++ b/test/integration-ebpf/src/strncmp.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{ cty::c_long, @@ -32,3 +32,8 @@ pub fn test_bpf_strncmp(ctx: ProbeContext) -> Result<(), c_long> { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/tcx.rs b/test/integration-ebpf/src/tcx.rs index 09741540..55a7971c 100644 --- a/test/integration-ebpf/src/tcx.rs +++ b/test/integration-ebpf/src/tcx.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{bindings::tcx_action_base::TCX_NEXT, macros::classifier, programs::TcContext}; @@ -13,3 +13,8 @@ pub fn tcx_next(_ctx: TcContext) -> i32 { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/test.rs b/test/integration-ebpf/src/test.rs index df6db808..b21a6ff9 100644 --- a/test/integration-ebpf/src/test.rs +++ b/test/integration-ebpf/src/test.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{ bindings::{bpf_ret_code, xdp_action}, @@ -58,3 +58,8 @@ pub fn test_flow(_ctx: FlowDissectorContext) -> u32 { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/two_progs.rs b/test/integration-ebpf/src/two_progs.rs index a1c500d4..039f8a91 100644 --- a/test/integration-ebpf/src/two_progs.rs +++ b/test/integration-ebpf/src/two_progs.rs @@ -1,7 +1,7 @@ // Two programs in the same ELF section -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{macros::tracepoint, programs::TracePointContext}; @@ -19,3 +19,8 @@ pub fn test_tracepoint_two(_ctx: TracePointContext) -> u32 { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/uprobe_cookie.rs b/test/integration-ebpf/src/uprobe_cookie.rs index b3e2d497..a01a90bf 100644 --- a/test/integration-ebpf/src/uprobe_cookie.rs +++ b/test/integration-ebpf/src/uprobe_cookie.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{ EbpfContext as _, helpers, @@ -23,3 +23,8 @@ pub fn uprobe_cookie(ctx: ProbeContext) { fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +} diff --git a/test/integration-ebpf/src/xdp_sec.rs b/test/integration-ebpf/src/xdp_sec.rs index 50d30713..98fb1f57 100644 --- a/test/integration-ebpf/src/xdp_sec.rs +++ b/test/integration-ebpf/src/xdp_sec.rs @@ -1,5 +1,5 @@ -#![no_std] -#![no_main] +#![cfg_attr(target_arch = "bpf", no_std)] +#![cfg_attr(target_arch = "bpf", no_main)] use aya_ebpf::{bindings::xdp_action::XDP_PASS, macros::xdp, programs::XdpContext}; @@ -24,3 +24,8 @@ probe!(xdp_frags_devmap, (frags, map = "devmap")); fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } + +#[cfg(not(target_arch = "bpf"))] +fn main() { + panic!("This should only ever be called from its eBPF entrypoint") +}