Skip to content

Commit

Permalink
Merge pull request #737 from aya-rs/more-kernels
Browse files Browse the repository at this point in the history
github: run integration tests on local kernel
  • Loading branch information
tamird committed Oct 16, 2023
2 parents 35e21ae + fa6f5e2 commit 8154fb7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion test/integration-test/src/tests/relocations.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use aya::{programs::UProbe, Bpf};
use aya::{programs::UProbe, util::KernelVersion, Bpf};
use test_log::test;

#[test]
Expand All @@ -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();
Expand Down
9 changes: 5 additions & 4 deletions test/integration-test/src/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8154fb7

Please sign in to comment.