integration-test: remove all sleeps

pull/786/head
Tamir Duberstein 1 year ago
parent f0f09ac16e
commit 0a144a0e69
No known key found for this signature in database

@ -17,7 +17,7 @@ struct {
__uint(max_entries, 1); __uint(max_entries, 1);
} map_2 SEC(".maps"); } map_2 SEC(".maps");
SEC("tracepoint") SEC("uprobe")
int bpf_prog(void *ctx) { int bpf_prog(void *ctx) {
__u32 key = 0; __u32 key = 0;
__u64 twenty_four = 24; __u64 twenty_four = 24;

@ -36,11 +36,12 @@ fn multiple_btf_maps() {
let map_1: Array<_, u64> = bpf.take_map("map_1").unwrap().try_into().unwrap(); let map_1: Array<_, u64> = bpf.take_map("map_1").unwrap().try_into().unwrap();
let map_2: Array<_, u64> = bpf.take_map("map_2").unwrap().try_into().unwrap(); let map_2: Array<_, u64> = bpf.take_map("map_2").unwrap().try_into().unwrap();
let prog: &mut TracePoint = bpf.program_mut("bpf_prog").unwrap().try_into().unwrap(); let prog: &mut UProbe = bpf.program_mut("bpf_prog").unwrap().try_into().unwrap();
prog.load().unwrap(); prog.load().unwrap();
prog.attach("sched", "sched_switch").unwrap(); prog.attach(Some("trigger_bpf_program"), 0, "/proc/self/exe", None)
.unwrap();
thread::sleep(time::Duration::from_secs(3)); trigger_bpf_program();
let key = 0; let key = 0;
let val_1 = map_1.get(&key, 0).unwrap(); let val_1 = map_1.get(&key, 0).unwrap();
@ -50,6 +51,12 @@ fn multiple_btf_maps() {
assert_eq!(val_2, 42); assert_eq!(val_2, 42);
} }
#[no_mangle]
#[inline(never)]
pub extern "C" fn trigger_bpf_program() {
core::hint::black_box(trigger_bpf_program);
}
fn poll_loaded_program_id(name: &str) -> impl Iterator<Item = Option<u32>> + '_ { fn poll_loaded_program_id(name: &str) -> impl Iterator<Item = Option<u32>> + '_ {
std::iter::once(true) std::iter::once(true)
.chain(std::iter::repeat(false)) .chain(std::iter::repeat(false))

@ -40,7 +40,7 @@ fn use_map_with_rbpf() {
assert_eq!(object.programs.len(), 1); assert_eq!(object.programs.len(), 1);
assert_matches!( assert_matches!(
object.programs["bpf_prog"].section, object.programs["bpf_prog"].section,
ProgramSection::TracePoint { .. } ProgramSection::UProbe { .. }
); );
// Initialize maps: // Initialize maps:

@ -1,5 +1,3 @@
use std::time::Duration;
use aya::{programs::UProbe, Bpf}; use aya::{programs::UProbe, Bpf};
#[test] #[test]
@ -7,7 +5,6 @@ fn relocations() {
let bpf = load_and_attach("test_64_32_call_relocs", crate::RELOCATIONS); let bpf = load_and_attach("test_64_32_call_relocs", crate::RELOCATIONS);
trigger_relocations_program(); trigger_relocations_program();
std::thread::sleep(Duration::from_millis(100));
let m = aya::maps::Array::<_, u64>::try_from(bpf.map("RESULTS").unwrap()).unwrap(); let m = aya::maps::Array::<_, u64>::try_from(bpf.map("RESULTS").unwrap()).unwrap();
assert_eq!(m.get(&0, 0).unwrap(), 1); assert_eq!(m.get(&0, 0).unwrap(), 1);
@ -24,7 +21,6 @@ fn text_64_64_reloc() {
m.set(1, 2, 0).unwrap(); m.set(1, 2, 0).unwrap();
trigger_relocations_program(); trigger_relocations_program();
std::thread::sleep(Duration::from_millis(100));
assert_eq!(m.get(&0, 0).unwrap(), 2); assert_eq!(m.get(&0, 0).unwrap(), 2);
assert_eq!(m.get(&1, 0).unwrap(), 3); assert_eq!(m.get(&1, 0).unwrap(), 3);

Loading…
Cancel
Save