From fa6f5e2532736ba7bb77b7007f9c7be1d14bbb6e Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Wed, 9 Aug 2023 17:04:03 -0400 Subject: [PATCH] github: run integration tests on local kernel This tests on 6.2.0-1012-azure (see https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20231001.1). --- .github/workflows/ci.yml | 6 +++++- test/integration-test/src/tests/relocations.rs | 8 +++++++- test/integration-test/src/tests/smoke.rs | 9 +++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39ab82de..59bff5bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -246,7 +246,11 @@ jobs: find test/.tmp -name '*.deb' -print0 | xargs -t -0 -I {} \ sh -c "dpkg --fsys-tarfile {} | tar -C test/.tmp --wildcards --extract '*vmlinuz*' --file -" - - name: Run integration tests + - name: Run local integration tests + if: runner.os == 'Linux' + run: cargo xtask integration-test local + + - name: Run virtualized integration tests run: find test/.tmp -name 'vmlinuz-*' | xargs -t cargo xtask integration-test vm # Provides a single status check for the entire build workflow. diff --git a/test/integration-test/src/tests/relocations.rs b/test/integration-test/src/tests/relocations.rs index e47e11f1..9c5dab7f 100644 --- a/test/integration-test/src/tests/relocations.rs +++ b/test/integration-test/src/tests/relocations.rs @@ -1,4 +1,4 @@ -use aya::{programs::UProbe, Bpf}; +use aya::{programs::UProbe, util::KernelVersion, Bpf}; use test_log::test; #[test] @@ -15,6 +15,12 @@ fn relocations() { #[test] fn text_64_64_reloc() { + let kernel_version = KernelVersion::current().unwrap(); + if kernel_version < KernelVersion::new(5, 13, 0) { + eprintln!("skipping test on kernel {kernel_version:?}, support for bpf_for_each_map_elem was added in 5.13.0; see https://github.com/torvalds/linux/commit/69c087b"); + return; + } + let mut bpf = load_and_attach("test_text_64_64_reloc", crate::TEXT_64_64_RELOC); let mut m = aya::maps::Array::<_, u64>::try_from(bpf.map_mut("RESULTS").unwrap()).unwrap(); diff --git a/test/integration-test/src/tests/smoke.rs b/test/integration-test/src/tests/smoke.rs index 7aadef1a..2b01938d 100644 --- a/test/integration-test/src/tests/smoke.rs +++ b/test/integration-test/src/tests/smoke.rs @@ -9,14 +9,14 @@ use crate::utils::NetNsGuard; #[test] fn xdp() { - let _netns = NetNsGuard::new(); - let kernel_version = KernelVersion::current().unwrap(); if kernel_version < KernelVersion::new(5, 18, 0) { eprintln!("skipping test on kernel {kernel_version:?}, support for BPF_F_XDP_HAS_FRAGS was added in 5.18.0; see https://github.com/torvalds/linux/commit/c2f2cdb"); return; } + let _netns = NetNsGuard::new(); + let mut bpf = Bpf::load(crate::PASS).unwrap(); let dispatcher: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap(); dispatcher.load().unwrap(); @@ -47,13 +47,14 @@ fn two_progs() { #[test] fn extension() { - let _netns = NetNsGuard::new(); - let kernel_version = KernelVersion::current().unwrap(); if kernel_version < KernelVersion::new(5, 9, 0) { eprintln!("skipping test on kernel {kernel_version:?}, XDP uses netlink"); return; } + + let _netns = NetNsGuard::new(); + let mut bpf = Bpf::load(crate::MAIN).unwrap(); let pass: &mut Xdp = bpf.program_mut("xdp_pass").unwrap().try_into().unwrap(); pass.load().unwrap();