diff --git a/test/cases/000_smoke/010_ext/test.sh b/test/cases/000_smoke/010_ext/test.sh index d8d1559f..695849a5 100755 --- a/test/cases/000_smoke/010_ext/test.sh +++ b/test/cases/000_smoke/010_ext/test.sh @@ -18,6 +18,8 @@ clean_up() { trap clean_up EXIT # Test code goes here +min_kernel_version 5.9 + compile_c_ebpf "$(pwd)/main.bpf.c" compile_c_ebpf "$(pwd)/${NAME}.bpf.c" compile_user "$(pwd)/${NAME}.rs" diff --git a/test/cases/_lib/lib.sh b/test/cases/_lib/lib.sh index 384aea6d..2df42b8f 100644 --- a/test/cases/_lib/lib.sh +++ b/test/cases/_lib/lib.sh @@ -9,6 +9,9 @@ AYA_TMPDIR="${RT_PROJECT_ROOT}/_tmp" # Directory for VM images AYA_IMGDIR="${RT_PROJECT_ROOT}/_images" +# Cancel Exit Code +RT_CANCEL=253 + # Test Architecture if [ -z "${AYA_TEST_ARCH}" ]; then AYA_TEST_ARCH="$(uname -m)" @@ -239,3 +242,20 @@ cleanup_vm() { stop_vm fi } + +# Check that host machine meets minimum kernel requirement +# Must be in format {major}.{minor} +min_kernel_version() { + target_major=$(echo "$1" | cut -d '.' -f1) + target_minor=$(echo "$1" | cut -d '.' -f2) + + vm_kernel=$(exec_vm uname -r) + vm_major=$(echo "${vm_kernel}" | cut -d '.' -f1) + vm_minor=$(echo "${vm_kernel}" | cut -d '.' -f2) + + if [ "${vm_major}" -lt "${target_major}" ] || [ "${vm_minor}" -lt "${target_minor}" ]; then + echo "Test not supported on kernel ${vm_major}.${vm_minor}" + return ${RT_CANCEL} + fi + return 0 +} \ No newline at end of file