From df8c9743154589a22d95d0929cbe422565eb8459 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Tue, 1 Apr 2025 09:35:46 +0200 Subject: [PATCH] tests/: improve version detection Alpine Linux versions also contain the revision, and this needs to be taken into account when detecting it. Signed-off-by: Iker Pedrosa Reviewed-by: Dan Lavu --- tests/system/framework/hosts/base.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/system/framework/hosts/base.py b/tests/system/framework/hosts/base.py index 764c15aff..9146c7d4e 100644 --- a/tests/system/framework/hosts/base.py +++ b/tests/system/framework/hosts/base.py @@ -47,6 +47,7 @@ class BaseLinuxHost(MultihostHost[ShadowMultihostDomain]): self._distro_name: str = "unknown" self._distro_major: int = 0 self._distro_minor: int = 0 + self._revision: int = 0 def _distro_information(self): """ @@ -60,9 +61,13 @@ class BaseLinuxHost(MultihostHost[ShadowMultihostDomain]): self._distro_name = self._os_release["NAME"] if "VERSION_ID" not in self._os_release: return - if "." in self._os_release["VERSION_ID"]: - self._distro_major = int(self._os_release["VERSION_ID"].split(".", maxsplit=1)[0]) - self._distro_minor = int(self._os_release["VERSION_ID"].split(".", maxsplit=1)[1]) + if self._os_release["VERSION_ID"].count(".") == 2: + self._distro_major = int(self._os_release["VERSION_ID"].split(".")[0]) + self._distro_minor = int(self._os_release["VERSION_ID"].split(".")[1]) + self._revision = int(self._os_release["VERSION_ID"].split(".")[2]) + elif self._os_release["VERSION_ID"].count(".") == 1: + self._distro_major = int(self._os_release["VERSION_ID"].split(".")[0]) + self._distro_minor = int(self._os_release["VERSION_ID"].split(".")[1]) else: self._distro_major = int(self._os_release["VERSION_ID"]) -- 2.47.2