Skip to content

Commit

Permalink
Add connecting lines to test output.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinling committed Oct 17, 2024
1 parent 480fc38 commit 22397cf
Show file tree
Hide file tree
Showing 27 changed files with 12,209 additions and 12,055 deletions.
21 changes: 9 additions & 12 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2170,26 +2170,27 @@ mod tests {
cap: &mut CaptureReader,
item: &Item,
mode: ViewMode,
depth: usize
) -> String
where CaptureReader: ItemSource<Item, ViewMode>,
ViewMode: Copy
{
let mut summary = cap.description(item, false).unwrap();
let mut summary = format!("{} {}",
cap.connectors(mode, item).unwrap(),
cap.description(item, false).unwrap()
);
let (_completion, num_children) =
cap.item_children(Some(item), mode).unwrap();
let child_ids = 0..num_children;
for (n, child_summary) in child_ids
.map(|child_id| {
let child = cap.child_item(item, child_id).unwrap();
summarize_item(cap, &child, mode, depth + 1)
summarize_item(cap, &child, mode)
})
.dedup_with_count()
{
summary += "\n";
summary += &" ".repeat(depth + 1);
if n > 1 {
summary += &format!("{} times: {}", n, &child_summary);
summary += &format!("{} ({} times)", &child_summary, n);
} else {
summary += &child_summary;
}
Expand All @@ -2201,16 +2202,12 @@ mod tests {
cap: &mut CaptureReader,
item: &Item,
mode: ViewMode,
depth: usize,
writer: &mut dyn Write
)
where CaptureReader: ItemSource<Item, ViewMode>,
ViewMode: Copy
{
let summary = summarize_item(cap, item, mode, depth);
for _ in 0..depth {
writer.write(b" ").unwrap();
}
let summary = summarize_item(cap, item, mode);
writer.write(summary.as_bytes()).unwrap();
writer.write(b"\n").unwrap();
}
Expand Down Expand Up @@ -2252,14 +2249,14 @@ mod tests {
let num_items = reader.item_index.len();
for item_id in 0 .. num_items {
let item = reader.item(None, mode, item_id).unwrap();
write_item(&mut reader, &item, mode, 0, &mut traf_out_writer);
write_item(&mut reader, &item, mode, &mut traf_out_writer);
}
let dev_out_file = File::create(dev_out_path.clone()).unwrap();
let mut dev_out_writer = BufWriter::new(dev_out_file);
let num_devices = reader.devices.len() - 1;
for device_id in 0 .. num_devices {
let item = reader.item(None, (), device_id).unwrap();
write_item(&mut reader, &item, (), 0, &mut dev_out_writer);
write_item(&mut reader, &item, (), &mut dev_out_writer);
}
}
for (ref_path, out_path) in [
Expand Down
88 changes: 44 additions & 44 deletions tests/analyzer-test-bad-cable/devices-reference.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
Device 1: USB Analyzer Test Device
Device descriptor
Length: 18 bytes
Type: 0x01
USB Version: 2.00
Class: 0x00: (Defined at Interface level)
Subclass: 0x00
Protocol: 0x00
Max EP0 packet size: 64 bytes
Vendor ID: 0x1209: Generic
Product ID: 0x000A: pid.codes Test PID
Version: 0.01
Manufacturer string: #1 'Cynthion Project'
Product string: #2 'USB Analyzer Test Device'
Serial string: (none)
Configuration 1
Configuration descriptor
Length: 9 bytes
Type: 0x02
Total length: 25 bytes
Number of interfaces: 1
Configuration number: 1
Configuration string: (none)
Attributes: 0x80
Max power: 500mA
Interface 0: Vendor Specific Class
Interface descriptor
Length: 9 bytes
Type: 0x04
Interface number: 0
Alternate setting: 0
Number of endpoints: 1
Class: 0xFF: Vendor Specific Class
Subclass: 0xFF: Vendor Specific Subclass
Protocol: 0xFF: Vendor Specific Protocol
Interface string: (none)
Endpoint 1 IN (interrupt)
Endpoint descriptor
Length: 7 bytes
Type: 0x05
Endpoint address: 0x81
Attributes: 0x03
Max packet size: 512 bytes
Interval: 0x05
Device 1: USB Analyzer Test Device
Device descriptor
Length: 18 bytes
Type: 0x01
USB Version: 2.00
Class: 0x00: (Defined at Interface level)
Subclass: 0x00
Protocol: 0x00
Max EP0 packet size: 64 bytes
Vendor ID: 0x1209: Generic
Product ID: 0x000A: pid.codes Test PID
Version: 0.01
Manufacturer string: #1 'Cynthion Project'
Product string: #2 'USB Analyzer Test Device'
Serial string: (none)
Configuration 1
Configuration descriptor
Length: 9 bytes
Type: 0x02
Total length: 25 bytes
Number of interfaces: 1
Configuration number: 1
Configuration string: (none)
Attributes: 0x80
Max power: 500mA
Interface 0: Vendor Specific Class
Interface descriptor
Length: 9 bytes
Type: 0x04
Interface number: 0
Alternate setting: 0
Number of endpoints: 1
Class: 0xFF: Vendor Specific Class
Subclass: 0xFF: Vendor Specific Subclass
Protocol: 0xFF: Vendor Specific Protocol
Interface string: (none)
Endpoint 1 IN (interrupt)
Endpoint descriptor
Length: 7 bytes
Type: 0x05
Endpoint address: 0x81
Attributes: 0x03
Max packet size: 512 bytes
Interval: 0x05
Loading

0 comments on commit 22397cf

Please sign in to comment.