Skip to content

Commit d1495ee

Browse files
committed
Test large bulk transfers with high-speed devices
Suggested when reviewing the parent commit. I remember manually adding extra test cases when I was testing, so it'll be nice to have these automatically tested when the device can support it.
1 parent d805c04 commit d1495ee

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tests/test_class_host/device.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ pub struct DeviceHandles {
1313
}
1414

1515
impl DeviceHandles {
16+
/// Indicates if this device is (true) or isn't (false) a
17+
/// high-speed device.
18+
pub fn is_high_speed(&self) -> bool {
19+
self.handle.device().speed() == rusb::Speed::High
20+
}
1621
/// Returns the max packet size for the `TestClass` bulk endpoint(s).
1722
pub fn bulk_max_packet_size(&self) -> u16 {
1823
self.config_descriptor

tests/test_class_host/tests.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,13 @@ fn interface_descriptor(dev, _out) {
164164
}
165165

166166
fn bulk_loopback(dev, _out) {
167+
let mut lens = vec![0, 1, 2, 32, 63, 64, 65, 127, 128, 129];
168+
if dev.is_high_speed() {
169+
lens.extend([255, 256, 257, 511, 512, 513, 1023, 1024, 1025]);
170+
}
171+
167172
let max_packet_size: usize = dev.bulk_max_packet_size().into();
168-
for len in &[0, 1, 2, 32, 63, 64, 65, 127, 128, 129] {
173+
for len in &lens {
169174
let data = random_data(*len);
170175

171176
assert_eq!(

0 commit comments

Comments
 (0)