From 1bf8c14919bc5b52a28fb33f5ef317f52487b1f7 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Mon, 13 Apr 2026 03:52:19 +0200 Subject: [PATCH] tstest: fix kernel version parsing for Debian-style version strings The kernel version parser used strings.Cut with "-" to handle versions like "5.4.0-76-generic", but Debian uses "+" in versions like "6.12.41+deb13-amd64". Use strings.IndexAny to find the first "-" or "+" and truncate there. Fixes TestKernelVersion on Debian systems. Change-Id: I70e5f95682d54baf908e51f9f4b51c130b00aaaa Co-Authored-By: Claude Opus 4.6 Signed-off-by: Avery Pennarun --- tstest/kernel_linux.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tstest/kernel_linux.go b/tstest/kernel_linux.go index ab7c0d529..fd021d092 100644 --- a/tstest/kernel_linux.go +++ b/tstest/kernel_linux.go @@ -37,9 +37,12 @@ func KernelVersion() (major, minor, patch int) { return 0, 0, 0 } - // Patch version may have additional info after a hyphen (e.g., "0-76-generic") - // Extract just the numeric part before any hyphen - patchStr, _, _ := strings.Cut(parts[2], "-") + // Patch version may have additional info after a hyphen or plus (e.g., "0-76-generic" or "41+deb13-amd64") + // Extract just the numeric part before any hyphen or plus + patchStr := parts[2] + if idx := strings.IndexAny(patchStr, "-+"); idx != -1 { + patchStr = patchStr[:idx] + } patch, err = strconv.Atoi(patchStr) if err != nil {