Skip to content

Commit c78c4a1

Browse files
committed
Improve apt.test_provides unit test
The unit test was failing on recent versions of Debian and Ubuntu because the `login` package is no longer installing the binary on `/bin/login` but rather on `/usr/bin/login`. We have added a function which will retrieve the binary path depending on the distro as well. Resolves: avocado-framework#6028 Signed-off-by: David Negreira <[email protected]>
1 parent a44d5ab commit c78c4a1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

selftests/unit/utils/software_manager.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ def apt_supported_distro():
1313
return distro.detect().name in ["debian", "Ubuntu"]
1414

1515

16+
def login_binary_path(distro_name, distro_version):
17+
"""Retrieve the login binary path based on the distro version""""
18+
if distro_name == "Ubuntu":
19+
if float(distro_version) >= 24.04:
20+
return "/usr/bin/login"
21+
if distro_name == "debian":
22+
if distro_version == "trixie":
23+
return "/usr/bin/login"
24+
return "/bin/login"
25+
26+
1627
@unittest.skipUnless(os.getuid() == 0, "This test requires root privileges")
1728
@unittest.skipUnless(apt_supported_distro(), "Unsupported distro")
1829
class Apt(unittest.TestCase):
1930
def test_provides(self):
2031
sm = manager.SoftwareManager()
21-
self.assertEqual(sm.provides("/bin/login"), "login")
32+
distro_name = distro.detect().name
33+
distro_version = distro.detect().version
34+
login_path = login_binary_path(distro_name, distro_version)
35+
self.assertEqual(sm.provides(login_path), "login")
2236
self.assertTrue(isinstance(sm.backend, backends.apt.AptBackend))
2337

2438

0 commit comments

Comments
 (0)