Fix Windows wake discovery for unsupported USB interfaces
This commit is contained in:
parent
19358a0fff
commit
e277d34c20
2 changed files with 26 additions and 5 deletions
|
|
@ -4907,7 +4907,9 @@ def find_wake_pico(
|
||||||
raise ConfigManagerError(
|
raise ConfigManagerError(
|
||||||
"native child did not identify native-hub project firmware"
|
"native child did not identify native-hub project firmware"
|
||||||
)
|
)
|
||||||
except (ConfigManagerError, usb.core.USBError) as exc:
|
except (ConfigManagerError, usb.core.USBError, NotImplementedError) as exc:
|
||||||
|
# PyUSB maps LIBUSB_ERROR_NOT_SUPPORTED to NotImplementedError,
|
||||||
|
# not USBError. Try another child when its driver is unavailable.
|
||||||
last_error = exc
|
last_error = exc
|
||||||
if isinstance(exc, usb.core.USBError) and not (
|
if isinstance(exc, usb.core.USBError) and not (
|
||||||
native
|
native
|
||||||
|
|
|
||||||
|
|
@ -930,6 +930,12 @@ def test_switch2_wake_cli_selects_device_and_reports_limited_evidence(
|
||||||
capsys: pytest.CaptureFixture[str],
|
capsys: pytest.CaptureFixture[str],
|
||||||
wake_clock: list[float],
|
wake_clock: list[float],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
# This test mocks non-Windows discovery; do not enumerate real Windows USB.
|
||||||
|
monkeypatch.setattr(
|
||||||
|
config_manager,
|
||||||
|
"sys",
|
||||||
|
SimpleNamespace(platform="linux", stderr=config_manager.sys.stderr),
|
||||||
|
)
|
||||||
device = WakeDevice([wake_response(), wake_response(3, 23)])
|
device = WakeDevice([wake_response(), wake_response(3, 23)])
|
||||||
other = WakeDevice([wake_response()])
|
other = WakeDevice([wake_response()])
|
||||||
other.address = 8
|
other.address = 8
|
||||||
|
|
@ -4194,15 +4200,21 @@ def test_windows_wake_groups_siblings_without_opening_hub(
|
||||||
assert windows_usb.closed == [right]
|
assert windows_usb.closed == [right]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"error",
|
||||||
|
(
|
||||||
|
config_manager.usb.core.USBError("no WinUSB interface", error_code=-12),
|
||||||
|
NotImplementedError("Operation not supported or unimplemented on this platform"),
|
||||||
|
),
|
||||||
|
)
|
||||||
def test_windows_wake_uses_sibling_with_available_vendor_driver(
|
def test_windows_wake_uses_sibling_with_available_vendor_driver(
|
||||||
windows_usb: WakeDiscoveryBackend,
|
windows_usb: WakeDiscoveryBackend,
|
||||||
|
error: Exception,
|
||||||
) -> None:
|
) -> None:
|
||||||
hub = windows_usb.add((0x057E, 0x2068), 7)
|
hub = windows_usb.add((0x057E, 0x2068), 7)
|
||||||
right = windows_usb.add((0x057E, 0x2066), 8, ports=(1, 1), parent=hub)
|
right = windows_usb.add((0x057E, 0x2066), 8, ports=(1, 1), parent=hub)
|
||||||
left = windows_usb.add((0x057E, 0x2067), 9, ports=(1, 2), parent=hub)
|
left = windows_usb.add((0x057E, 0x2067), 9, ports=(1, 2), parent=hub)
|
||||||
windows_usb.nodes[right].claim_error = config_manager.usb.core.USBError(
|
windows_usb.nodes[right].claim_error = error
|
||||||
"no WinUSB interface", error_code=-12
|
|
||||||
)
|
|
||||||
device = config_manager.find_wake_pico(None, None, timeout=0)
|
device = config_manager.find_wake_pico(None, None, timeout=0)
|
||||||
assert device.address == 9
|
assert device.address == 9
|
||||||
assert windows_usb.opened == [right, left]
|
assert windows_usb.opened == [right, left]
|
||||||
|
|
@ -4387,12 +4399,19 @@ def test_windows_wake_hub_without_children_never_opens_root(
|
||||||
assert windows_usb.controls == []
|
assert windows_usb.controls == []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"error",
|
||||||
|
(
|
||||||
|
config_manager.usb.core.USBError("no vendor driver", error_code=-12),
|
||||||
|
NotImplementedError("Operation not supported or unimplemented on this platform"),
|
||||||
|
),
|
||||||
|
)
|
||||||
def test_windows_wake_missing_driver_reports_safe_binding_guidance(
|
def test_windows_wake_missing_driver_reports_safe_binding_guidance(
|
||||||
windows_usb: WakeDiscoveryBackend,
|
windows_usb: WakeDiscoveryBackend,
|
||||||
|
error: Exception,
|
||||||
) -> None:
|
) -> None:
|
||||||
hub = windows_usb.add((0x057E, 0x2068), 7)
|
hub = windows_usb.add((0x057E, 0x2068), 7)
|
||||||
child = windows_usb.add((0x057E, 0x2066), 8, ports=(1, 1), parent=hub)
|
child = windows_usb.add((0x057E, 0x2066), 8, ports=(1, 1), parent=hub)
|
||||||
error = config_manager.usb.core.USBError("no vendor driver", error_code=-12)
|
|
||||||
windows_usb.nodes[child].claim_error = error
|
windows_usb.nodes[child].claim_error = error
|
||||||
with pytest.raises(config_manager.ConfigManagerError) as raised:
|
with pytest.raises(config_manager.ConfigManagerError) as raised:
|
||||||
config_manager.find_wake_pico(None, None, timeout=0)
|
config_manager.find_wake_pico(None, None, timeout=0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue