Skip to content

Commit ed52dd6

Browse files
committed
[tests,usb] Make the test harness explicitely request a USB context
On QEMU, the USB host needs to be spawned and this only happens if we request a USB context. Signed-off-by: Amaury Pouly <[email protected]>
1 parent 946df96 commit ed52dd6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sw/host/tests/chip/usb/usb_harness.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::process::Command;
99
use std::time::Duration;
1010

1111
use opentitanlib::test_utils::init::InitializeTest;
12+
use opentitanlib::transport::Capability;
1213
use opentitanlib::uart::console::UartConsole;
1314

1415
use usb::{UsbDeviceHandle, UsbOpts, port_path_string};
@@ -76,6 +77,16 @@ fn main() -> Result<()> {
7677
opts.init.init_logging();
7778
let transport = opts.init.init_target()?;
7879

80+
transport
81+
.capabilities()?
82+
.request(Capability::USB)
83+
.ok()
84+
.context("This transport does not support USB")?;
85+
86+
// Certain backend such as QEMU will not enumerate USB device until
87+
// we request the USB context.
88+
let _usb_context = transport.usb().context("Cannot get USB context")?;
89+
7990
// Wait until test is running.
8091
let uart = transport.uart("console")?;
8192
UartConsole::wait_for(&*uart, r"Running [^\r\n]*", opts.timeout)?;

0 commit comments

Comments
 (0)