Skip to content

Commit

Permalink
MacOSX: ensure a sysprofile key is unique
Browse files Browse the repository at this point in the history
closes: #1721

Reported-by: Christian Roeder <zchroeder@gmail.com>
  • Loading branch information
Gonéri Le Bouder committed Jul 18, 2012
1 parent 2907865 commit 7219789
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 61 deletions.
Expand Up @@ -41,7 +41,6 @@ sub _getDisplays {

foreach my $videoName (keys %{$infos->{'Graphics/Displays'}}) {
my $videoCardInfo = $infos->{'Graphics/Displays'}->{$videoName};

foreach my $displayName (keys %{$videoCardInfo->{Displays}}) {
next if $displayName eq 'Display Connector';
next if $displayName eq 'Display';
Expand Down
7 changes: 7 additions & 0 deletions lib/FusionInventory/Agent/Tools/MacOS.pm
Expand Up @@ -75,6 +75,13 @@ sub getSystemProfilerInfos {

# create a new node, and push it to the stack
my $parent_node = $parents[-1]->[0];

my $i;
my $keyL = $key;
while (defined($parent_node->{$key})) {
$key = $keyL . '_' . $i++;
}

$parent_node->{$key} = {};
push (@parents, [ $parent_node->{$key}, $level, $key ]);
}
Expand Down
80 changes: 20 additions & 60 deletions t/inventory/macos/videos.t
Expand Up @@ -8,81 +8,41 @@ use Test::More;
use FusionInventory::Agent::Task::Inventory::Input::MacOS::Videos;

my %tests = (
'10.4-powerpc' => {
MONITORS => [
{
DESCRIPTION => 'ASUS VH222',
CAPTION => 'ASUS VH222'
}
],
VIDEOS => [
{
NAME => 'NVIDIA GeForce 6600',
RESOLUTION => '1360x768',
CHIPSET => 'GeForce 6600',
MEMORY => '256',
PCISLOT => 'SLOT-1'
}
]
},
'10.5-powerpc' =>
{

'10.6.5-dual-monitor' => {
MONITORS => [
{
DESCRIPTION => 'ASUS VH222',
CAPTION => 'ASUS VH222'
}
],
VIDEOS => [
{
NAME => 'NVIDIA GeForce 6600',
RESOLUTION => '1680x1050',
CHIPSET => 'GeForce 6600',
MEMORY => '256',
PCISLOT => 'SLOT-1'
}
]
},
'10.6-intel' => {
MONITORS => [
DESCRIPTION => 'E2441',
CAPTION => 'E2441'
},
{
DESCRIPTION => 'iMac',
CAPTION => 'iMac'
DESCRIPTION => 'E2441_0',
CAPTION => 'E2441_0'
}
],
VIDEOS => [
{
NAME => 'ATI Radeon HD 2600 Pro',
RESOLUTION => '1920x1200',
CHIPSET => 'ATI,RadeonHD2600',
MEMORY => '256',
PCISLOT => undef
}
]
},
'10.6.6-intel' => {
MONITORS => [
{
DESCRIPTION => 'Color LCD',
CAPTION => 'Color LCD'
}
],
VIDEOS => [
NAME => 'ATI Radeon HD 5770',
RESOLUTION => '1920x1080',
CHIPSET => 'ATI Radeon HD 5770',
MEMORY => '1024',
PCISLOT => 'Slot-1'
},
{
NAME => 'Intel GMA 950',
RESOLUTION => '1280x800',
CHIPSET => 'GMA 950',
MEMORY => '64',
PCISLOT => undef
NAME => 'ATI Radeon HD 5770',
RESOLUTION => '1920x1080',
CHIPSET => 'ATI Radeon HD 5770',
MEMORY => '1024',
PCISLOT => 'Slot-1'
}
]
}
);

plan tests => scalar keys %tests;

use Data::Dumper;
foreach my $test (keys %tests) {
my $file = "resources/macos/system_profiler/$test";
my %displays = FusionInventory::Agent::Task::Inventory::Input::MacOS::Videos::_getDisplays(file => $file);
is_deeply(\%displays, $tests{$test}, $test);
is_deeply(\%displays, $tests{$test}, $test) or print Dumper(\%displays);
}

0 comments on commit 7219789

Please sign in to comment.