Skip to content

Commit

Permalink
read_hardware_test: rewritten, with minimal stubs.
Browse files Browse the repository at this point in the history
Deleted the real-world data because they are huge.

Reusing probe_netcard_factory (from commit
befef4d, to be merged), to have minimal
stubs.
  • Loading branch information
mvidner committed Aug 14, 2014
1 parent 34a2970 commit 5f4b758
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 508 deletions.
36 changes: 36 additions & 0 deletions test/factories/probe_netcard.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# A factory for the elements contained in SCR.Read(path(".probe.netcard"))
# @return one item for a .probe.netcard list
def probe_netcard_factory(num)
num = num.to_s
dev_name = "eth#{num}"

{
"bus" => "Virtio",
"class_id" => 2,
"dev_name" => dev_name,
"dev_names" => [dev_name],
"device" => "Ethernet Card #{num}",
"device_id" => 262145,
"driver" => "virtio_net",
"driver_module" => "virtio_net",
"drivers" => [
{
"active" => true,
"modprobe" => true,
"modules" => [["virtio_net", ""]]
}
],
"modalias" => "virtio:d00000001v00001AF4",
"model" => "Virtio Ethernet Card #{num}",
"resource" => {
"hwaddr" => [ {"addr" => "52:54:00:5b:b2:7#{num}"} ],

This comment has been minimized.

Copy link
@mchf

mchf Aug 14, 2014

Member

num should be converted into hex here and checked if it is num <= 0xF

"link"=> [ {"state" => true} ]
},
"sub_class_id" => 0,
"sysfs_bus_id" => "virtio#{num}",
"sysfs_id" => "/devices/pci0000:00/0000:00:03.0/virtio#{num}",
"unique_key" => "vWuh.VIRhsc57kT#{num}",
"vendor" => "Virtio",
"vendor_id" => 286740
}
end
Loading

1 comment on commit 5f4b758

@mchf
Copy link
Member

@mchf mchf commented on 5f4b758 Aug 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to create generic probe helper. Your approach means that when I want to use the probe helper elsewhere I'll probably need to touch the helper even fix this test. Also I currently don't see any reason (of course there can be) for stubbing Arch ... In general I prefer minimal stubbing.

Please sign in to comment.