From 492feb2147da669487cfde5c3ad5633137f84245 Mon Sep 17 00:00:00 2001 From: martinsoees Date: Fri, 12 Jul 2024 03:43:23 -0400 Subject: [PATCH] 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 --- .../integration-test/src/tests/relocations.rs | 51 +++---------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 98adf044..d4c44e3f 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -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() { - 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() { +fn 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) - .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(), - }; + let mut ebpf = EbpfLoader::new() + .ignore_maps_by_name(&[disable_map_name]) + .set_global("RINGBUF_SUPPORTED", &0, true) + .load(bytes) + .unwrap(); let prog: &mut UProbe = ebpf.program_mut(name).unwrap().try_into().unwrap(); prog.load().unwrap();