FusionInventory-Agent
view release on metacpan or search on metacpan
t/agent/tools/unix.t view on Meta::CPAN
FILESYSTEM => undef
},
{
VOLUMN => '/dev/hd9var',
TOTAL => '256',
FREE => '177',
TYPE => '/var',
FILESYSTEM => undef
},
{
VOLUMN => '/dev/hd3',
TOTAL => '4096',
FREE => '837',
TYPE => '/tmp',
FILESYSTEM => undef
},
{
VOLUMN => '/dev/fwdump',
TOTAL => '128',
FREE => '127',
TYPE => '/var/adm/ras/platform',
FILESYSTEM => undef
},
{
VOLUMN => '/dev/hd1',
TOTAL => '2048',
FREE => '1027',
TYPE => '/home',
FILESYSTEM => undef
},
{
VOLUMN => '/dev/hd11admin',
TOTAL => '128',
FREE => '127',
TYPE => '/admin',
FILESYSTEM => undef
},
{
VOLUMN => '/dev/hd10opt',
TOTAL => '128',
FREE => '13',
TYPE => '/opt',
FILESYSTEM => undef
}
]
);
my @dhcp_leases_test = (
{
file => 'dhclient-wlan0-1.lease',
result => '192.168.0.254',
if => 'wlan0'
},
{
file => 'dhclient-wlan0-2.lease',
result => '192.168.10.1',
if => 'wlan0'
},
);
my %busybox_ps_tests = (
busybox => [
{
VIRTUALMEMORY => '2536',
PID => '1',
CMD => 'init',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '2',
CMD => '[kthreadd]',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '3',
CMD => '[ksoftirqd/0]',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '6',
CMD => '[migration/0]',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '7',
CMD => '[migration/1]',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '9',
CMD => '[ksoftirqd/1]',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '11',
CMD => '[migration/2]',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '13',
CMD => '[ksoftirqd/2]',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '14',
CMD => '[migration/3]',
USER => 'root'
},
{
VIRTUALMEMORY => '0',
PID => '16',
CMD => '[ksoftirqd/3]',
USER => 'root'
},
t/agent/tools/unix.t view on Meta::CPAN
'aix-6.1a' => {
'172.16.0.80' => '127.0.0.1',
'172.16.0.0' => '172.16.0.80',
'172.16.7.255' => '172.16.0.80',
'default' => '172.16.0.254',
'10.0.0.0' => '10.0.0.103',
'10/21' => '10.0.0.103',
'10.0.0.103' => '127.0.0.1',
'192.0.0/24' => '172.16.0.254',
'10.0.7.255' => '10.0.0.103',
'127/8' => '127.0.0.1',
'172.16/21' => '172.16.0.80',
'39/16' => '172.16.0.21'
},
'aix-6.1b' => {
'192.168.4.1' => '127.0.0.1',
'192.168.1.1' => '127.0.0.1',
'192.168.203/24' => '192.168.203.101',
'192.168.1.255' => '192.168.1.1',
'10/8' => '10.3.0.254',
'192.168.203.101' => '127.0.0.1',
'10.3.40.101' => '127.0.0.1',
'192.168.203.0' => '192.168.203.101',
'192.168.3.1' => '127.0.0.1',
'192.168.4/24' => '192.168.4.1',
'192.168.3.255' => '192.168.3.1',
'192.168.203.255' => '192.168.203.101',
'192.168.4.0' => '192.168.4.1',
'10.3.0.0' => '10.3.40.101',
'default' => '10.3.0.253',
'10.3/16' => '10.3.40.101',
'192.168.3/24' => '192.168.3.1',
'192.168.1/24' => '192.168.1.1',
'192.168.201/24' => '192.168.203.254',
'192.168.1.0' => '192.168.1.1',
'192.168.4.255' => '192.168.4.1',
'192.168.3.0' => '192.168.3.1',
'10.3.255.255' => '10.3.40.101',
'127/8' => '127.0.0.1'
},
linux1 => {
'0.0.0.0' => '192.168.0.254',
'192.168.0.0' => '0.0.0.0'
},
macosx1 => {
'192.168.0.254' => 'f4:ca:e5:42:38:37',
'127.0.0.1' => '127.0.0.1',
'192.168.0.27' => '127.0.0.1',
'default' => '192.168.0.254'
}
);
my %mount_tests = (
linux => [ qw/ext4 tmpfs proc sysfs devpts binfmt_misc/ ],
darwin => [ qw/local union/ ],
freebsd => [ qw/ufs/ ]
);
plan tests =>
(scalar keys %df_tests) +
(scalar keys %busybox_ps_tests) +
(scalar keys %other_ps_tests) +
(scalar keys %netstat_tests) +
(scalar keys %mount_tests) +
(scalar @dhcp_leases_test);
foreach my $test (keys %df_tests) {
my $file = "resources/generic/df/$test";
my @infos = getFilesystemsFromDf(file => $file);
cmp_deeply(\@infos, $df_tests{$test}, "$test df parsing");
}
foreach my $test (keys %busybox_ps_tests) {
my $file = "resources/generic/ps/$test";
my @processes = FusionInventory::Agent::Tools::Unix::_getProcessesBusybox(file => $file);
cmp_deeply(\@processes, $busybox_ps_tests{$test}, "$test ps parsing");
}
foreach my $test (keys %other_ps_tests) {
my $file = "resources/generic/ps/$test";
my @processes = FusionInventory::Agent::Tools::Unix::_getProcessesOther(file => $file);
cmp_deeply(\@processes, $other_ps_tests{$test}, "$test ps parsing");
}
foreach my $test (@dhcp_leases_test) {
my $file = "resources/generic/dhcp/$test->{file}";
my $server = FusionInventory::Agent::Tools::Unix::_parseDhcpLeaseFile(undef, $test->{if}, $file);
ok(
$server && ($server eq $test->{result}),
"Parse DHCP lease"
);
}
foreach my $test (keys %netstat_tests) {
my $file = "resources/generic/netstat/$test";
my $routes = getRoutingTable(file => $file);
cmp_deeply($routes, $netstat_tests{$test}, $test);
}
foreach my $test (keys %mount_tests) {
my $file = "resources/generic/mount/$test";
my @types = getFilesystemsTypesFromMount(file => $file);
cmp_deeply(\@types, $mount_tests{$test}, $test);
}
( run in 3.506 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )