From 04202a9419b81bd60e9190a9d8913c00006e92f9 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 17 Oct 2024 20:36:50 +0200 Subject: [PATCH] fixup! tests/usb: Test the USB portal via pytest, dbusmock and umockdev --- .github/workflows/Containerfile | 6 +++++- .github/workflows/container.yml | 2 +- meson.build | 1 + tests/meson.build | 6 +++++- tests/test_usb.py | 10 ++++++++-- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Containerfile b/.github/workflows/Containerfile index 20f9212df..f96f23b57 100644 --- a/.github/workflows/Containerfile +++ b/.github/workflows/Containerfile @@ -44,7 +44,11 @@ RUN apt install -y --no-install-recommends \ python3-pytest \ python3-pytest-xdist \ python3-dbusmock \ - python3-dbus + python3-dbus \ + libumockdev0 \ + libumockdev-dev \ + umockdev \ + gir1.2-umockdev-1.0 # Install doc dependencies RUN apt install -y --no-install-recommends \ diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index aad973a77..ade45c8e3 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -1,5 +1,5 @@ env: - IMAGE_TAG: 20241015-2 + IMAGE_TAG: 20241017-3 on: workflow_call: diff --git a/meson.build b/meson.build index d58a1dd57..85db20a21 100644 --- a/meson.build +++ b/meson.build @@ -116,6 +116,7 @@ libportal_dep = dependency('libportal', pipewire_dep = dependency('libpipewire-0.3', version: '>= 0.2.90') libsystemd_dep = dependency('libsystemd', required: get_option('systemd')) gudev_dep = dependency('gudev-1.0', required: get_option('gudev')) +umockdev_dep = dependency('umockdev-1.0') bwrap = find_program('bwrap', required: get_option('sandboxed-image-validation')) diff --git a/tests/meson.build b/tests/meson.build index 9051e3a50..3037be103 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -284,7 +284,11 @@ python = pymod.find_installation( required: get_option('pytest'), ) -enable_pytest = pytest.found() and python.found() and python.language_version().version_compare('>=3.9') +enable_pytest = \ + pytest.found() and \ + python.found() and \ + python.language_version().version_compare('>=3.9') and \ + umockdev_dep.found() if enable_pytest subdir('templates') diff --git a/tests/test_usb.py b/tests/test_usb.py index c8520e6d2..08f55a38d 100644 --- a/tests/test_usb.py +++ b/tests/test_usb.py @@ -290,17 +290,23 @@ def test_acquire(self, portal_mock, app_id): "00001", ) + possible_vendors = ["04a9", "04aa"] + usb_intf = portal_mock.get_dbus_interface() devices = usb_intf.EnumerateDevices({}) assert len(devices) == 2 (id1, dev_info1) = devices[0] assert id1 assert dev_info1 - assert dev_info1["properties"]["ID_VENDOR_ID"] == "04a9" + vendor_id = dev_info1["properties"]["ID_VENDOR_ID"] + assert vendor_id in possible_vendors + possible_vendors.remove(vendor_id) (id2, dev_info2) = devices[1] assert id2 assert dev_info2 - assert dev_info2["properties"]["ID_VENDOR_ID"] == "04aa" + vendor_id = dev_info2["properties"]["ID_VENDOR_ID"] + assert vendor_id in possible_vendors + possible_vendors.remove(vendor_id) request = portal_mock.create_request() response = request.call(