From 76bb45b38c379d3316763056a9bb0c606dacd7ce Mon Sep 17 00:00:00 2001 From: Mattia Meleleo Date: Fri, 6 Oct 2023 01:50:48 +0200 Subject: [PATCH] fix features test --- testing/testrunner/tests.go | 44 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/testing/testrunner/tests.go b/testing/testrunner/tests.go index 116a1428..333e847d 100644 --- a/testing/testrunner/tests.go +++ b/testing/testrunner/tests.go @@ -18,28 +18,30 @@ import ( ) func TestFeaturesCorrect(et *EventsTraceInstance) { - var buf syscall.Utsname - if err := syscall.Uname(&buf); err != nil { + var utsname syscall.Utsname + if err := syscall.Uname(&utsname); err != nil { TestFail(fmt.Sprintf("Failed to run uname: %s", err)) } - archBytes := []byte{} - for _, b := range buf.Machine { - if b == 0 { - break + int8ArrayToString := func(arr [65]int8) string { + var buf []byte + for _, el := range arr { + buf = append(buf, byte(el)) } - - archBytes = append(archBytes, byte(b)) + return string(buf) + } + contains := func(s []string, str string) bool { + for _, el := range s { + if el == str { + return true + } + } + return false } - arch := string(archBytes) - // BPF trampolines are only supported on x86 at present. - // - // As of June 2022, there is a patchset circulating that will add support - // to ARM64 (https://lwn.net/Articles/899093/). This check should be - // updated when that is merged into the mainline such that it ensures BPF - // trampolines are disabled on all aarch64 kernels pre-. + arch := int8ArrayToString(utsname.Machine) + kernelVersion := int8ArrayToString(utsname.Release) + switch arch { case "x86_64": // All x86 kernels in the CI test matrix currently enable bpf @@ -49,9 +51,15 @@ func TestFeaturesCorrect(et *EventsTraceInstance) { // handle it here. AssertTrue(et.InitMsg.Features.BpfTramp) case "aarch64": - AssertFalse(et.InitMsg.Features.BpfTramp) + hasBpfTramp := []string{"6.2.0", "6.3.0", "6.4.0", "6.4.16", "6.5.0"} + + if contains(hasBpfTramp, kernelVersion) { + AssertTrue(et.InitMsg.Features.BpfTramp) + } else { + AssertFalse(et.InitMsg.Features.BpfTramp) + } default: - TestFail(fmt.Sprintf("Unknown arch %s, please add to the TestFeaturesCorrect test", arch)) + TestFail(fmt.Sprintf("unknown arch %s, please add to the TestFeaturesCorrect test", arch)) } }