Remove relocation test by type

The 'ignore_map_by_type' function has been removed. Also renamed test function and simplified the relocation builder since 'by_name' is the only option now
pull/968/head
martinsoees 2 months ago
parent 787d08b031
commit 492feb2147

@ -1,36 +1,12 @@
use std::collections::HashSet;
use aya::{programs::UProbe, util::KernelVersion, Ebpf, EbpfLoader};
use aya_obj::generated::bpf_map_type;
use test_log::test;
enum DisableMapRelocation<'a> {
ByType(bpf_map_type),
ByName(&'a str),
}
#[test]
fn test_ignored_map_relocation_by_type() {
fn ignored_map_relocation_by_name() {
let mut ebpf = relocation_load_and_attach(
"test_ignored_map_relocation",
crate::IGNORE_MAP,
DisableMapRelocation::ByType(bpf_map_type::BPF_MAP_TYPE_RINGBUF),
);
let perf = ebpf.take_map("PERFBUF");
let ring = ebpf.take_map("RINGBUF");
assert!(perf.is_some());
assert!(ring.is_none());
}
#[test]
fn test_ignored_map_relocation_by_name() {
let mut ebpf = relocation_load_and_attach(
"test_ignored_map_relocation",
crate::IGNORE_MAP,
DisableMapRelocation::ByName("RINGBUF"),
"RINGBUF",
);
let perf = ebpf.take_map("PERFBUF");
@ -76,24 +52,13 @@ fn text_64_64_reloc() {
fn relocation_load_and_attach(
name: &str,
bytes: &[u8],
disable_type: DisableMapRelocation,
disable_map_name: &str,
) -> Ebpf {
let mut ebpf = match disable_type {
DisableMapRelocation::ByType(bmt) => {
let mut set = HashSet::new();
set.insert(bmt);
EbpfLoader::new()
.ignore_maps_by_type(set)
let mut ebpf = EbpfLoader::new()
.ignore_maps_by_name(&[disable_map_name])
.set_global("RINGBUF_SUPPORTED", &0, true)
.load(bytes)
.unwrap()
}
DisableMapRelocation::ByName(name) => EbpfLoader::new()
.ignore_maps_by_name(&[name])
.set_global("RINGBUF_SUPPORTED", &0, true)
.load(bytes)
.unwrap(),
};
.unwrap();
let prog: &mut UProbe = ebpf.program_mut(name).unwrap().try_into().unwrap();
prog.load().unwrap();

Loading…
Cancel
Save