integration-test: Add test for 2 progs in same section

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
pull/413/head
Dave Tucker 1 year ago
parent c72aab5f7b
commit 6d92119fbc

@ -38,3 +38,7 @@ path = "src/relocations.rs"
[[bin]] [[bin]]
name = "bpf_probe_read" name = "bpf_probe_read"
path = "src/bpf_probe_read.rs" path = "src/bpf_probe_read.rs"
[[bin]]
name = "two_progs"
path = "src/two_progs.rs"

@ -0,0 +1,21 @@
// Two programs in the same ELF section
#![no_std]
#![no_main]
use aya_bpf::{macros::tracepoint, programs::TracePointContext};
#[tracepoint]
pub fn test_tracepoint_one(_ctx: TracePointContext) -> u32 {
0
}
#[tracepoint]
pub fn test_tracepoint_two(_ctx: TracePointContext) -> u32 {
0
}
#[cfg(not(test))]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}

@ -13,6 +13,7 @@ pub const NAME_TEST: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/n
pub const PASS: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/pass")); pub const PASS: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/pass"));
pub const TEST: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/test")); pub const TEST: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/test"));
pub const RELOCATIONS: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/relocations")); pub const RELOCATIONS: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/relocations"));
pub const TWO_PROGS: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/two_progs"));
pub const BPF_PROBE_READ: &[u8] = pub const BPF_PROBE_READ: &[u8] =
include_bytes_aligned!(concat!(env!("OUT_DIR"), "/bpf_probe_read")); include_bytes_aligned!(concat!(env!("OUT_DIR"), "/bpf_probe_read"));

@ -1,5 +1,5 @@
use aya::{ use aya::{
programs::{Extension, Xdp, XdpFlags}, programs::{Extension, TracePoint, Xdp, XdpFlags},
util::KernelVersion, util::KernelVersion,
Bpf, BpfLoader, Bpf, BpfLoader,
}; };
@ -22,6 +22,28 @@ fn xdp() {
dispatcher.attach("lo", XdpFlags::default()).unwrap(); dispatcher.attach("lo", XdpFlags::default()).unwrap();
} }
#[test]
fn two_progs() {
let mut bpf = Bpf::load(crate::TWO_PROGS).unwrap();
let prog_one: &mut TracePoint = bpf
.program_mut("test_tracepoint_one")
.unwrap()
.try_into()
.unwrap();
prog_one.load().unwrap();
prog_one.attach("sched", "sched_switch").unwrap();
let prog_two: &mut TracePoint = bpf
.program_mut("test_tracepoint_two")
.unwrap()
.try_into()
.unwrap();
prog_two.load().unwrap();
prog_two.attach("sched", "sched_switch").unwrap();
}
#[test] #[test]
fn extension() { fn extension() {
let _netns = NetNsGuard::new(); let _netns = NetNsGuard::new();

Loading…
Cancel
Save