diff --git a/Cargo.toml b/Cargo.toml index cfda2f5d..3ce5005f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,6 +91,7 @@ rustversion = { version = "1.0.0", default-features = false } syn = { version = "2", default-features = false } tempfile = { version = "3", default-features = false } test-case = { version = "3.1.0", default-features = false } +test-log = { version = "0.2.13", default-features = false } testing_logger = { version = "0.1.1", default-features = false } thiserror = { version = "1", default-features = false } tokio = { version = "1.24.0", default-features = false } diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml index 4db38be6..6ef15833 100644 --- a/test/integration-test/Cargo.toml +++ b/test/integration-test/Cargo.toml @@ -10,6 +10,7 @@ assert_matches = { workspace = true } aya = { workspace = true } aya-log = { workspace = true } aya-obj = { workspace = true } +env_logger = { workspace = true } epoll = { workspace = true } futures = { workspace = true, features = ["std"] } libc = { workspace = true } @@ -19,6 +20,7 @@ object = { workspace = true, features = ["elf", "read_core", "std"] } rand = { workspace = true, features = ["std", "std_rng"] } rbpf = { workspace = true } test-case = { workspace = true } +test-log = { workspace = true, features = ["log"] } tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time"] } [build-dependencies] diff --git a/test/integration-test/src/tests/bpf_probe_read.rs b/test/integration-test/src/tests/bpf_probe_read.rs index 4c425507..5d7cf6ab 100644 --- a/test/integration-test/src/tests/bpf_probe_read.rs +++ b/test/integration-test/src/tests/bpf_probe_read.rs @@ -1,4 +1,5 @@ use aya::{maps::Array, programs::UProbe, Bpf}; +use test_log::test; const RESULT_BUF_LEN: usize = 1024; diff --git a/test/integration-test/src/tests/elf.rs b/test/integration-test/src/tests/elf.rs index 9c68144f..3a5ad0a3 100644 --- a/test/integration-test/src/tests/elf.rs +++ b/test/integration-test/src/tests/elf.rs @@ -1,4 +1,5 @@ use object::{Object, ObjectSymbol}; +use test_log::test; #[test] fn test_maps() { diff --git a/test/integration-test/src/tests/load.rs b/test/integration-test/src/tests/load.rs index 685867e9..6707a99e 100644 --- a/test/integration-test/src/tests/load.rs +++ b/test/integration-test/src/tests/load.rs @@ -16,6 +16,7 @@ use aya::{ Bpf, }; use aya_obj::programs::XdpAttachType; +use test_log::test; const MAX_RETRIES: usize = 100; const RETRY_DURATION: Duration = Duration::from_millis(10); diff --git a/test/integration-test/src/tests/log.rs b/test/integration-test/src/tests/log.rs index be99948b..c7980e0c 100644 --- a/test/integration-test/src/tests/log.rs +++ b/test/integration-test/src/tests/log.rs @@ -6,6 +6,7 @@ use std::{ use aya::{programs::UProbe, Bpf}; use aya_log::BpfLogger; use log::{Level, Log, Record}; +use test_log::test; #[no_mangle] #[inline(never)] @@ -37,7 +38,7 @@ struct CapturedLog<'a> { pub target: Cow<'a, str>, } -#[tokio::test] +#[test(tokio::test)] async fn log() { let mut bpf = Bpf::load(crate::LOG).unwrap(); diff --git a/test/integration-test/src/tests/rbpf.rs b/test/integration-test/src/tests/rbpf.rs index d2aeafd8..900d1462 100644 --- a/test/integration-test/src/tests/rbpf.rs +++ b/test/integration-test/src/tests/rbpf.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use assert_matches::assert_matches; use aya_obj::{generated::bpf_insn, programs::XdpAttachType, Object, ProgramSection}; +use test_log::test; #[test] fn run_with_rbpf() { diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index 9e7d5719..e47e11f1 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -1,4 +1,5 @@ use aya::{programs::UProbe, Bpf}; +use test_log::test; #[test] fn relocations() { diff --git a/test/integration-test/src/tests/ring_buf.rs b/test/integration-test/src/tests/ring_buf.rs index ca222848..927d80a9 100644 --- a/test/integration-test/src/tests/ring_buf.rs +++ b/test/integration-test/src/tests/ring_buf.rs @@ -17,6 +17,7 @@ use aya::{ }; use aya_obj::generated::BPF_RINGBUF_HDR_SZ; use rand::Rng as _; +use test_log::test; use tokio::{ io::unix::AsyncFd, time::{sleep, Duration}, @@ -175,7 +176,7 @@ pub extern "C" fn ring_buf_trigger_ebpf_program(arg: u64) { // to fill the ring_buf. We just ensure that the number of events we see is sane given // what the producer sees, and that the logic does not hang. This exercises interleaving // discards, successful commits, and drops due to the ring_buf being full. -#[tokio::test(flavor = "multi_thread")] +#[test(tokio::test(flavor = "multi_thread"))] async fn ring_buf_async_with_drops() { let WithData( RingBufTest { @@ -282,7 +283,7 @@ async fn ring_buf_async_with_drops() { ); } -#[tokio::test(flavor = "multi_thread")] +#[test(tokio::test(flavor = "multi_thread"))] async fn ring_buf_async_no_drop() { let WithData( RingBufTest { @@ -380,7 +381,7 @@ fn ring_buf_epoll_wakeup() { } // This test is like the above test but uses tokio and AsyncFd instead of raw epoll. -#[tokio::test] +#[test(tokio::test)] async fn ring_buf_asyncfd_events() { let RingBufTest { ring_buf, diff --git a/test/integration-test/src/tests/smoke.rs b/test/integration-test/src/tests/smoke.rs index 48c1600b..7aadef1a 100644 --- a/test/integration-test/src/tests/smoke.rs +++ b/test/integration-test/src/tests/smoke.rs @@ -3,6 +3,7 @@ use aya::{ util::KernelVersion, Bpf, BpfLoader, }; +use test_log::test; use crate::utils::NetNsGuard; diff --git a/test/integration-test/src/tests/xdp.rs b/test/integration-test/src/tests/xdp.rs index 092f280e..c756dd20 100644 --- a/test/integration-test/src/tests/xdp.rs +++ b/test/integration-test/src/tests/xdp.rs @@ -6,6 +6,7 @@ use aya::{ Bpf, }; use object::{Object, ObjectSection, ObjectSymbol, SymbolSection}; +use test_log::test; use crate::utils::NetNsGuard;