Skip to content

Commit

Permalink
tests/usb: Skip the removal tests when the UMockdev version is too old
Browse files Browse the repository at this point in the history
We disabled the test in CI because the tests were failing but we didn't
understand why in

06a5e50 ("test: Disable USB removal test in a container")

It turns out that UMockdev simply didn't send the remove event before
version 0.18.4. Let's change the skip condition to actually check for
the right thing instead of just disabling it in CI. This means that the
test will run in CI once ubuntu:latest does have the right version.
  • Loading branch information
swick committed Jan 7, 2025
1 parent 6dee7a1 commit 1827e0d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/test_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
import os
import gi
import subprocess

gi.require_version("UMockdev", "1.0")
from gi.repository import GLib, UMockdev # noqa E402
Expand All @@ -22,6 +23,16 @@ def umockdev():
return UMockdev.Testbed.new()


def umockdev_has_working_remove():
# umockdev only generates remove events since version 0.18.4
# https://github.com/martinpitt/umockdev/releases/tag/0.18.4
required = (0, 18, 4)

result = subprocess.run(["umockdev-run", "--version"], stdout=subprocess.PIPE)
version = tuple(map(int, result.stdout.decode("UTF-8").strip().split(".")))
return all(v >= r for v, r in zip(version, required))


class TestUsb:
_num_devices = 0

Expand Down Expand Up @@ -188,7 +199,9 @@ def cb_device_events(session_handle, events):
)

@pytest.mark.parametrize("usb_queries", ["vnd:04a9", None])
@pytest.mark.skipif(xdp.is_in_container(), reason="Test fail in containers")
@pytest.mark.skipif(
not umockdev_has_working_remove(), reason="UMockdev version 0.18.4 required"
)
def test_device_remove(self, portals, dbus_con, app_id, usb_queries, umockdev):
usb_intf = xdp.get_portal_iface(dbus_con, "Usb")

Expand Down

0 comments on commit 1827e0d

Please sign in to comment.