Skip to content

Commit

Permalink
use Test::Deep for comparaisons
Browse files Browse the repository at this point in the history
It allows to use regexp for some keys whose values are more
susceptibles to change, as they come from pci.id database.
  • Loading branch information
guillomovitch committed Dec 24, 2012
1 parent 40d9dc7 commit 04d0ae9
Showing 1 changed file with 48 additions and 47 deletions.
95 changes: 48 additions & 47 deletions t/inventory/generic/pci/controllers.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ use strict;
use warnings;

use Test::More;
use Test::Deep;

use FusionInventory::Agent::Task::Inventory::Input::Generic::PCI::Controllers;

my %tests = (
'dell-xt2' => [
{
NAME => 'Mobile 4 Series Chipset Memory Controller Hub',
NAME => re('^Mobile 4 Series Chipset Memory Controller Hub'),
TYPE => 'Host bridge',
CAPTION => 'Mobile 4 Series Chipset Memory Controller Hub',
CAPTION => re('^Mobile 4 Series Chipset Memory Controller Hub'),
DRIVER => 'agpgart',
PCISLOT => '00:00.0',
PCICLASS => '0600',
Expand All @@ -21,9 +22,9 @@ my %tests = (
PCIID => '8086:2a40'
},
{
NAME => 'Mobile 4 Series Chipset Integrated Graphics Controller',
NAME => re('^Mobile 4 Series Chipset Integrated Graphics Controller'),
TYPE => 'VGA compatible controller',
CAPTION => 'Mobile 4 Series Chipset Integrated Graphics Controller',
CAPTION => re('^Mobile 4 Series Chipset Integrated Graphics Controller'),
DRIVER => 'i915',
PCISLOT => '00:02.0',
PCICLASS => '0300',
Expand All @@ -32,19 +33,19 @@ my %tests = (
PCIID => '8086:2a42'
},
{
NAME => 'Mobile 4 Series Chipset Integrated Graphics Controller',
NAME => re('^Mobile 4 Series Chipset Integrated Graphics Controller'),
TYPE => 'Display controller',
CAPTION => 'Mobile 4 Series Chipset Integrated Graphics Controller',
CAPTION => re('^Mobile 4 Series Chipset Integrated Graphics Controller'),
PCISLOT => '00:02.1',
PCICLASS => '0380',
MANUFACTURER => 'Intel Corporation',
REV => '07',
PCIID => '8086:2a43'
},
{
NAME => '82567LM Gigabit Network Connection',
NAME => re('^82567LM Gigabit Network Connection'),
TYPE => 'Ethernet controller',
CAPTION => '82567LM Gigabit Network Connection',
CAPTION => re('^82567LM Gigabit Network Connection'),
DRIVER => 'e1000e',
PCISLOT => '00:19.0',
PCICLASS => '0200',
Expand All @@ -53,9 +54,9 @@ my %tests = (
PCIID => '8086:10f5'
},
{
NAME => '82801I (ICH9 Family) USB UHCI Controller #4',
NAME => re('^82801I \([^)]+\) USB UHCI Controller #4'),
TYPE => 'USB controller',
CAPTION => '82801I (ICH9 Family) USB UHCI Controller #4',
CAPTION => re('^82801I \([^)]+\) USB UHCI Controller #4'),
DRIVER => 'uhci_hcd',
PCISLOT => '00:1a.0',
PCICLASS => '0c03',
Expand All @@ -64,9 +65,9 @@ my %tests = (
PCIID => '8086:2937'
},
{
NAME => '82801I (ICH9 Family) USB UHCI Controller #5',
NAME => re('^82801I \([^)]+\) USB UHCI Controller #5'),
TYPE => 'USB controller',
CAPTION => '82801I (ICH9 Family) USB UHCI Controller #5',
CAPTION => re('^82801I \([^)]+\) USB UHCI Controller #5'),
DRIVER => 'uhci_hcd',
PCISLOT => '00:1a.1',
PCICLASS => '0c03',
Expand All @@ -75,9 +76,9 @@ my %tests = (
PCIID => '8086:2938'
},
{
NAME => '82801I (ICH9 Family) USB UHCI Controller #6',
NAME => re('^82801I \([^)]+\) USB UHCI Controller #6'),
TYPE => 'USB controller',
CAPTION => '82801I (ICH9 Family) USB UHCI Controller #6',
CAPTION => re('^82801I \([^)]+\) USB UHCI Controller #6'),
DRIVER => 'uhci_hcd',
PCISLOT => '00:1a.2',
PCICLASS => '0c03',
Expand All @@ -86,9 +87,9 @@ my %tests = (
PCIID => '8086:2939'
},
{
NAME => '82801I (ICH9 Family) USB2 EHCI Controller #2',
NAME => re('^82801I \([^)]+\) USB2 EHCI Controller #2'),
TYPE => 'USB controller',
CAPTION => '82801I (ICH9 Family) USB2 EHCI Controller #2',
CAPTION => re('^82801I \([^)]+\) USB2 EHCI Controller #2'),
DRIVER => 'ehci_hcd',
PCISLOT => '00:1a.7',
PCICLASS => '0c03',
Expand All @@ -97,9 +98,9 @@ my %tests = (
PCIID => '8086:293c'
},
{
NAME => '82801I (ICH9 Family) HD Audio Controller',
NAME => re('^82801I \([^)]+\) HD Audio Controller'),
TYPE => 'Audio device',
CAPTION => '82801I (ICH9 Family) HD Audio Controller',
CAPTION => re('^82801I \([^)]+\) HD Audio Controller'),
DRIVER => 'snd_hda_intel',
PCISLOT => '00:1b.0',
PCICLASS => '0403',
Expand All @@ -108,9 +109,9 @@ my %tests = (
PCIID => '8086:293e'
},
{
NAME => '82801I (ICH9 Family) PCI Express Port 1',
NAME => re('^82801I \([^)]+\) PCI Express Port 1'),
TYPE => 'PCI bridge',
CAPTION => '82801I (ICH9 Family) PCI Express Port 1',
CAPTION => re('^82801I \([^)]+\) PCI Express Port 1'),
DRIVER => 'pcieport',
PCISLOT => '00:1c.0',
PCICLASS => '0604',
Expand All @@ -119,9 +120,9 @@ my %tests = (
PCIID => '8086:2940'
},
{
NAME => '82801I (ICH9 Family) PCI Express Port 2',
NAME => re('^82801I \([^)]+\) PCI Express Port 2'),
TYPE => 'PCI bridge',
CAPTION => '82801I (ICH9 Family) PCI Express Port 2',
CAPTION => re('^82801I \([^)]+\) PCI Express Port 2'),
DRIVER => 'pcieport',
PCISLOT => '00:1c.1',
PCICLASS => '0604',
Expand All @@ -130,9 +131,9 @@ my %tests = (
PCIID => '8086:2942'
},
{
NAME => '82801I (ICH9 Family) PCI Express Port 4',
NAME => re('^82801I \([^)]+\) PCI Express Port 4'),
TYPE => 'PCI bridge',
CAPTION => '82801I (ICH9 Family) PCI Express Port 4',
CAPTION => re('^82801I \([^)]+\) PCI Express Port 4'),
DRIVER => 'pcieport',
PCISLOT => '00:1c.3',
PCICLASS => '0604',
Expand All @@ -141,9 +142,9 @@ my %tests = (
PCIID => '8086:2946'
},
{
NAME => '82801I (ICH9 Family) USB UHCI Controller #1',
NAME => re('^82801I \([^)]+\) USB UHCI Controller #1'),
TYPE => 'USB controller',
CAPTION => '82801I (ICH9 Family) USB UHCI Controller #1',
CAPTION => re('^82801I \([^)]+\) USB UHCI Controller #1'),
DRIVER => 'uhci_hcd',
PCISLOT => '00:1d.0',
PCICLASS => '0c03',
Expand All @@ -152,9 +153,9 @@ my %tests = (
PCIID => '8086:2934'
},
{
NAME => '82801I (ICH9 Family) USB UHCI Controller #2',
NAME => re('^82801I \([^)]+\) USB UHCI Controller #2'),
TYPE => 'USB controller',
CAPTION => '82801I (ICH9 Family) USB UHCI Controller #2',
CAPTION => re('^82801I \([^)]+\) USB UHCI Controller #2'),
DRIVER => 'uhci_hcd',
PCISLOT => '00:1d.1',
PCICLASS => '0c03',
Expand All @@ -163,9 +164,9 @@ my %tests = (
PCIID => '8086:2935'
},
{
NAME => '82801I (ICH9 Family) USB UHCI Controller #3',
NAME => re('^82801I \([^)]+\) USB UHCI Controller #3'),
TYPE => 'USB controller',
CAPTION => '82801I (ICH9 Family) USB UHCI Controller #3',
CAPTION => re('^82801I \([^)]+\) USB UHCI Controller #3'),
DRIVER => 'uhci_hcd',
PCISLOT => '00:1d.2',
PCICLASS => '0c03',
Expand All @@ -174,9 +175,9 @@ my %tests = (
PCIID => '8086:2936'
},
{
NAME => '82801I (ICH9 Family) USB2 EHCI Controller #1',
NAME => re('^82801I \([^)]+\) USB2 EHCI Controller #1'),
TYPE => 'USB controller',
CAPTION => '82801I (ICH9 Family) USB2 EHCI Controller #1',
CAPTION => re('^82801I \([^)]+\) USB2 EHCI Controller #1'),
DRIVER => 'ehci_hcd',
PCISLOT => '00:1d.7',
PCICLASS => '0c03',
Expand All @@ -185,29 +186,29 @@ my %tests = (
PCIID => '8086:293a'
},
{
NAME => '82801 Mobile PCI Bridge',
NAME => re('^82801 Mobile PCI Bridge'),
TYPE => 'PCI bridge',
CAPTION => '82801 Mobile PCI Bridge',
CAPTION => re('^82801 Mobile PCI Bridge'),
PCISLOT => '00:1e.0',
PCICLASS => '0604',
MANUFACTURER => 'Intel Corporation',
REV => '93',
PCIID => '8086:2448'
},
{
NAME => 'ICH9M-E LPC Interface Controller',
NAME => re('^ICH9M-E LPC Interface Controller'),
TYPE => 'ISA bridge',
CAPTION => 'ICH9M-E LPC Interface Controller',
CAPTION => re('^ICH9M-E LPC Interface Controller'),
PCISLOT => '00:1f.0',
PCICLASS => '0601',
MANUFACTURER => 'Intel Corporation',
REV => '03',
PCIID => '8086:2917'
},
{
NAME => '82801I (ICH9 Family) SMBus Controller',
NAME => re('^82801I \([^)]+\) SMBus Controller'),
TYPE => 'SMBus',
CAPTION => '82801I (ICH9 Family) SMBus Controller',
CAPTION => re('^82801I \([^)]+\) SMBus Controller'),
DRIVER => 'i801_smbus',
PCISLOT => '00:1f.3',
PCICLASS => '0c05',
Expand All @@ -216,9 +217,9 @@ my %tests = (
PCIID => '8086:2930'
},
{
NAME => 'PCIxx12 Cardbus Controller',
NAME => re('^PCIxx12 Cardbus Controller'),
TYPE => 'CardBus bridge',
CAPTION => 'PCIxx12 Cardbus Controller',
CAPTION => re('^PCIxx12 Cardbus Controller'),
DRIVER => 'yenta_cardbus',
PCISLOT => '02:01.0',
PCICLASS => '0607',
Expand All @@ -227,9 +228,9 @@ my %tests = (
PCIID => '104c:8039'
},
{
NAME => 'PCIxx12 OHCI Compliant IEEE 1394 Host Controller',
NAME => re('^PCIxx12 OHCI Compliant IEEE 1394 Host Controller'),
TYPE => 'FireWire (IEEE 1394)',
CAPTION => 'PCIxx12 OHCI Compliant IEEE 1394 Host Controller',
CAPTION => re('^PCIxx12 OHCI Compliant IEEE 1394 Host Controller'),
DRIVER => 'firewire_ohci',
PCISLOT => '02:01.1',
PCICLASS => '0c00',
Expand All @@ -238,9 +239,9 @@ my %tests = (
PCIID => '104c:803a'
},
{
NAME => 'PCIxx12 SDA Standard Compliant SD Host Controller',
NAME => re('^PCIxx12 SDA Standard Compliant SD Host Controller'),
TYPE => 'SD Host controller',
CAPTION => 'PCIxx12 SDA Standard Compliant SD Host Controller',
CAPTION => re('^PCIxx12 SDA Standard Compliant SD Host Controller'),
DRIVER => 'sdhci',
PCISLOT => '02:01.3',
PCICLASS => '0805',
Expand All @@ -249,9 +250,9 @@ my %tests = (
PCIID => '104c:803c'
},
{
NAME => 'WiFi Link 5100',
NAME => re('^WiFi Link 5100'),
TYPE => 'Network controller',
CAPTION => 'WiFi Link 5100',
CAPTION => re('^WiFi Link 5100'),
DRIVER => 'iwlwifi',
PCISLOT => '0c:00.0',
PCICLASS => '0280',
Expand All @@ -267,5 +268,5 @@ plan tests => scalar keys %tests;
foreach my $test (keys %tests) {
my $file = "resources/generic/lspci/$test";
my @controllers = FusionInventory::Agent::Task::Inventory::Input::Generic::PCI::Controllers::_getControllers(file => $file, datadir => 'share');
is_deeply(\@controllers, $tests{$test}, $test);
cmp_deeply(\@controllers, $tests{$test}, $test);
}

0 comments on commit 04d0ae9

Please sign in to comment.