Skip to content

Commit 76f6c6a

Browse files
committed
tests: add unit and functional tests for distro module
Add comprehensive test coverage for the distro module: - 24 new unit tests covering LinuxDistro, Probe methods, regex patterns, SUSEProbe custom logic, register_probe, detect scoring/fallback, Spec - 1 new functional test for local system detection - Update TEST_SIZE counts in check.py (unit: 976->1000, functional: 368->369) Coverage: 95% (untested: remote SSH session paths) Assisted-By: Cursor-Claude-4-Sonnet Signed-off-by: Harvey Lynden <hlynden@redhat.com>
1 parent b6bcc65 commit 76f6c6a

File tree

3 files changed

+323
-27
lines changed

3 files changed

+323
-27
lines changed

selftests/check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"job-api-check-tmp-directory-exists": 1,
2828
"nrunner-interface": 90,
2929
"nrunner-requirement": 28,
30-
"unit": 976,
30+
"unit": 1000,
3131
"jobs": 11,
32-
"functional-parallel": 368,
32+
"functional-parallel": 369,
3333
"functional-serial": 7,
3434
"optional-plugins": 0,
3535
"optional-plugins-golang": 2,

selftests/functional/utils/distro.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import os
2+
import platform
23

34
from avocado import Test
45
from avocado.core.exit_codes import AVOCADO_ALL_OK
56
from avocado.core.job import Job
67
from avocado.core.nrunner.runnable import Runnable
78
from avocado.core.suite import TestSuite
9+
from avocado.utils import distro
810

911

1012
class Distro(Test):
@@ -64,3 +66,28 @@ def test_debian_12_7(self):
6466
+ os.uname().machine.encode()
6567
+ b") version 12 release 7\n",
6668
)
69+
70+
71+
class DistroDetectLocal(Test):
72+
"""Tests distro detection on the local system without containers."""
73+
74+
def test_detect_current_system(self):
75+
"""Verify detect() returns a valid result for the running system."""
76+
result = distro.detect()
77+
self.assertIsInstance(result, distro.LinuxDistro)
78+
has_release_file = any(
79+
os.path.exists(p)
80+
for p in [
81+
"/etc/os-release",
82+
"/etc/redhat-release",
83+
"/etc/fedora-release",
84+
"/etc/debian_version",
85+
]
86+
)
87+
if has_release_file:
88+
self.assertNotEqual(
89+
result.name,
90+
distro.UNKNOWN_DISTRO_NAME,
91+
"detect() should identify a known distro on this system",
92+
)
93+
self.assertEqual(result.arch, platform.machine())

0 commit comments

Comments
 (0)