From 91a415f095bc182deac618b4b63e0e075fa3ef63 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sun, 9 Jul 2023 18:14:27 -0400 Subject: [PATCH] Skip relocation tests on unsupported kernels --- test/integration-test/tests/btf_relocations.rs | 16 ++++++++++++++++ test/integration-test/tests/load.rs | 10 ++++++---- test/integration-test/tests/smoke.rs | 5 +++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/test/integration-test/tests/btf_relocations.rs b/test/integration-test/tests/btf_relocations.rs index 34bc3dbe..069bc76c 100644 --- a/test/integration-test/tests/btf_relocations.rs +++ b/test/integration-test/tests/btf_relocations.rs @@ -1,4 +1,5 @@ use anyhow::{bail, Context as _, Result}; +use procfs::KernelVersion; use std::{path::PathBuf, process::Command, thread::sleep, time::Duration}; use tempfile::TempDir; @@ -60,6 +61,11 @@ fn relocate_enum() { #[test] fn relocate_enum_signed() { + let kernel_version = KernelVersion::current().unwrap(); + if kernel_version < KernelVersion::new(6, 0, 0) { + eprintln!("skipping test on kernel {kernel_version:?}, support for signed enum was added in 6.0.0; see https://github.com/torvalds/linux/commit/6089fb3"); + return; + } let test = RelocationTest { local_definition: r#" enum foo { D = -0x7AAAAAAA }; @@ -80,6 +86,11 @@ fn relocate_enum_signed() { #[test] fn relocate_enum64() { + let kernel_version = KernelVersion::current().unwrap(); + if kernel_version < KernelVersion::new(6, 0, 0) { + eprintln!("skipping test on kernel {kernel_version:?}, support for enum64 was added in 6.0.0; see https://github.com/torvalds/linux/commit/6089fb3"); + return; + } let test = RelocationTest { local_definition: r#" enum foo { D = 0xAAAAAAAABBBBBBBB }; @@ -100,6 +111,11 @@ fn relocate_enum64() { #[test] fn relocate_enum64_signed() { + let kernel_version = KernelVersion::current().unwrap(); + if kernel_version < KernelVersion::new(6, 0, 0) { + eprintln!("skipping test on kernel {kernel_version:?}, support for enum64 was added in 6.0.0; see https://github.com/torvalds/linux/commit/6089fb3"); + return; + } let test = RelocationTest { local_definition: r#" enum foo { D = -0xAAAAAAABBBBBBBB }; diff --git a/test/integration-test/tests/load.rs b/test/integration-test/tests/load.rs index d242338d..e27e46f0 100644 --- a/test/integration-test/tests/load.rs +++ b/test/integration-test/tests/load.rs @@ -131,8 +131,9 @@ fn unload_kprobe() { #[test] fn pin_link() { - if KernelVersion::current().unwrap() < KernelVersion::new(5, 9, 0) { - eprintln!("skipping test, XDP uses netlink"); + 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; } @@ -166,8 +167,9 @@ fn pin_link() { #[test] fn pin_lifecycle() { - if KernelVersion::current().unwrap() < KernelVersion::new(5, 9, 0) { - eprintln!("skipping test, XDP uses netlink"); + 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; } diff --git a/test/integration-test/tests/smoke.rs b/test/integration-test/tests/smoke.rs index b3006072..51c54555 100644 --- a/test/integration-test/tests/smoke.rs +++ b/test/integration-test/tests/smoke.rs @@ -17,8 +17,9 @@ fn xdp() { #[test] fn extension() { - if KernelVersion::current().unwrap() < KernelVersion::new(5, 9, 0) { - eprintln!("skipping test, XDP uses netlink"); + 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 main_bytes =