Remove dependency on bpftool in integration tests

pull/639/head
Tamir Duberstein 1 year ago
parent 5c86b7ee95
commit ff86f1385c
No known key found for this signature in database

@ -999,12 +999,14 @@ impl Iterator for ProgramsIter {
io_error, io_error,
}) })
.and_then(|fd| { .and_then(|fd| {
bpf_prog_get_info_by_fd(fd) let info = bpf_prog_get_info_by_fd(fd)
.map_err(|io_error| ProgramError::SyscallError { .map_err(|io_error| ProgramError::SyscallError {
call: "bpf_prog_get_info_by_fd".to_owned(), call: "bpf_prog_get_info_by_fd".to_owned(),
io_error, io_error,
}) })
.map(ProgramInfo) .map(ProgramInfo);
unsafe { libc::close(fd) };
info
}), }),
) )
} }

@ -1,11 +1,11 @@
use std::{convert::TryInto, process::Command, thread, time}; use std::{convert::TryInto as _, thread, time};
use aya::{ use aya::{
include_bytes_aligned, include_bytes_aligned,
maps::Array, maps::Array,
programs::{ programs::{
links::{FdLink, PinnedLink}, links::{FdLink, PinnedLink},
KProbe, TracePoint, Xdp, XdpFlags, loaded_programs, KProbe, TracePoint, Xdp, XdpFlags,
}, },
Bpf, Bpf,
}; };
@ -58,20 +58,10 @@ fn multiple_btf_maps() {
assert_eq!(val_2, 42); assert_eq!(val_2, 42);
} }
fn is_loaded(name: &str) -> bool {
let output = Command::new("bpftool").args(["prog"]).output();
let output = match output {
Err(e) => panic!("Failed to run 'bpftool prog': {e}"),
Ok(out) => out,
};
let stdout = String::from_utf8(output.stdout).unwrap();
stdout.contains(name)
}
macro_rules! assert_loaded { macro_rules! assert_loaded {
($name:literal, $loaded:expr) => { ($name:literal, $loaded:expr) => {
for i in 0..(MAX_RETRIES + 1) { for i in 0..(MAX_RETRIES + 1) {
let state = is_loaded($name); let state = loaded_programs().any(|prog| prog.unwrap().name() == $name.as_bytes());
if state == $loaded { if state == $loaded {
break; break;
} }

@ -193,7 +193,7 @@ EOF
exec_vm sudo dnf config-manager --set-enabled updates-testing exec_vm sudo dnf config-manager --set-enabled updates-testing
exec_vm sudo dnf config-manager --set-enabled updates-testing-modular exec_vm sudo dnf config-manager --set-enabled updates-testing-modular
echo "Installing dependencies" echo "Installing dependencies"
exec_vm sudo dnf install -qy bpftool llvm llvm-devel clang clang-devel zlib-devel exec_vm sudo dnf install -qy llvm llvm-devel clang clang-devel zlib-devel
exec_vm 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ exec_vm 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
-y --profile minimal --default-toolchain nightly --component rust-src --component clippy' -y --profile minimal --default-toolchain nightly --component rust-src --component clippy'
exec_vm 'echo source ~/.cargo/env >> ~/.bashrc' exec_vm 'echo source ~/.cargo/env >> ~/.bashrc'

@ -36,8 +36,13 @@ fn build(opts: &Options) -> Result<(), anyhow::Error> {
.args(&args) .args(&args)
.status() .status()
.expect("failed to build userspace"); .expect("failed to build userspace");
assert!(status.success()); match status.code() {
Ok(()) Some(code) => match code {
0 => Ok(()),
code => Err(anyhow::anyhow!("exited with status code: {code}")),
},
None => Err(anyhow::anyhow!("process terminated by signal")),
}
} }
/// Build and run the project /// Build and run the project

Loading…
Cancel
Save