From 6b6d81ccedd45546246c01c5ef58d488839d8072 Mon Sep 17 00:00:00 2001 From: Jianyong Wu Date: Fri, 15 Oct 2021 13:10:37 +0800 Subject: [PATCH] runtime: kernel version with '+' as suffix panic in parse The current kernel version parse lib can't process suffix '+', as the modified kernel version will add '+' as suffix, thus panic will occur. For example, if the current kernel version is "5.14.0-rc4+", test TestHostNetworkingRequested will panic: --- FAIL: TestHostNetworkingRequested (0.00s) panic: &{DistroName:ubuntu DistroVersion:18.04 KernelVersion:5.11.0-rc3+ Issue: Passed:[] Failed:[] Debug:true ActualEUID:0}: failed to check test constraints: error: Build meta data is empty Here, remove the suffix '+' in kernel version fix helper. Fixes: #2809 Signed-off-by: Jianyong Wu --- src/runtime/pkg/katatestutils/constraints.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/runtime/pkg/katatestutils/constraints.go b/src/runtime/pkg/katatestutils/constraints.go index 5ac50de1d0..d2f400b4b1 100644 --- a/src/runtime/pkg/katatestutils/constraints.go +++ b/src/runtime/pkg/katatestutils/constraints.go @@ -147,8 +147,15 @@ func getDistroDetails() (name, version string, err error) { // centos: 3.10.0-957.12.1.el7.x86_64 // fedora: 5.0.9-200.fc29.x86_64 // +// For some self compiled kernel, the kernel version will be with "+" as its suffix +// For example: +// 5.12.0-rc4+ +// These kernel version can't be parsed by the current lib and lead to panic +// therefore the '+' should be removed. +// func fixKernelVersion(version string) string { - return strings.Replace(version, "_", "-", -1) + version = strings.Replace(version, "_", "-", -1) + return strings.Replace(version, "+", "", -1) } // handleDistroName checks that the current distro is compatible with