]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests/: improve distribution detection
authorIker Pedrosa <ipedrosa@redhat.com>
Wed, 12 Mar 2025 13:59:38 +0000 (14:59 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 21 May 2025 08:04:42 +0000 (10:04 +0200)
openSUSE includes comment lines in `/etc/os-release` file and this can
cause some issues during the distribution detection. Ignore those lines
as they don't cause any effect on the system.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
tests/system/framework/hosts/base.py

index a5ee5d914e8446e8e2fe84f9e82872145b0e9dd7..764c15aff3e74812b07bb1522a19af4f51bfcb69 100644 (file)
@@ -54,7 +54,8 @@ class BaseLinuxHost(MultihostHost[ShadowMultihostDomain]):
         """
         self.logger.info(f"Detecting distro information on {self.hostname}")
         os_release = self.fs.read("/etc/os-release")
-        self._os_release = dict(csv.reader([x for x in os_release.splitlines() if x], delimiter="="))
+        valid_lines = [line for line in os_release.splitlines() if line and not line.startswith("#")]
+        self._os_release = dict(csv.reader(valid_lines, delimiter="="))
         if "NAME" in self._os_release:
             self._distro_name = self._os_release["NAME"]
         if "VERSION_ID" not in self._os_release: