#321 clean interface descriptions of null and trailing space
This commit is contained in:
@@ -150,6 +150,10 @@ sub interfaces {
|
|||||||
my $port = $i_descr->{$iid};
|
my $port = $i_descr->{$iid};
|
||||||
next unless defined $port;
|
next unless defined $port;
|
||||||
|
|
||||||
|
my $port = SNMP::Info::munge_null($port);
|
||||||
|
$port =~ s/^\s+//; $port =~ s/\s+$//;
|
||||||
|
next unless length $port;
|
||||||
|
|
||||||
if ( $seen{$port}++ ) {
|
if ( $seen{$port}++ ) {
|
||||||
# (#320) also fixup the port this is a duplicate of
|
# (#320) also fixup the port this is a duplicate of
|
||||||
$interfaces->{ $first_seen_as{$port} }
|
$interfaces->{ $first_seen_as{$port} }
|
||||||
|
|||||||
@@ -335,6 +335,10 @@ sub interfaces {
|
|||||||
my $port = $i_descr->{$iid};
|
my $port = $i_descr->{$iid};
|
||||||
next unless defined $port;
|
next unless defined $port;
|
||||||
|
|
||||||
|
my $port = SNMP::Info::munge_null($port);
|
||||||
|
$port =~ s/^\s+//; $port =~ s/\s+$//;
|
||||||
|
next unless length $port;
|
||||||
|
|
||||||
if ( $seen{$port}++ ) {
|
if ( $seen{$port}++ ) {
|
||||||
# (#320) also fixup the port this is a duplicate of
|
# (#320) also fixup the port this is a duplicate of
|
||||||
$interfaces->{ $first_seen_as{$port} }
|
$interfaces->{ $first_seen_as{$port} }
|
||||||
|
|||||||
@@ -50,18 +50,22 @@ sub setup : Tests(setup) {
|
|||||||
'_i_index' => 1,
|
'_i_index' => 1,
|
||||||
'_i_description' => 1,
|
'_i_description' => 1,
|
||||||
'store' => {
|
'store' => {
|
||||||
'i_index' => {1 => 1, 2 => 2, 3 => 3, 4 => 4},
|
'i_index' => { map {($_ => $_)} (1 .. 8) },
|
||||||
'i_description' => {
|
'i_description' => {
|
||||||
1 => 'Unique Interface Name',
|
1 => 'Unique Interface Name',
|
||||||
2 => 'Duplicate Interface Name',
|
2 => 'Duplicate Interface Name',
|
||||||
3 => 'Duplicate Interface Name'
|
3 => 'Duplicate Interface Name',
|
||||||
|
4 => "\0",
|
||||||
|
5 => "\0",
|
||||||
|
6 => " \0",
|
||||||
|
7 => "\0 ",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
$test->{info}->cache($cache_data);
|
$test->{info}->cache($cache_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub duplicates : Tests(2) {
|
sub interfaces : Tests(2) {
|
||||||
my $test = shift;
|
my $test = shift;
|
||||||
|
|
||||||
my $expected_data = {
|
my $expected_data = {
|
||||||
@@ -69,11 +73,15 @@ sub duplicates : Tests(2) {
|
|||||||
2 => 'Duplicate Interface Name (2)',
|
2 => 'Duplicate Interface Name (2)',
|
||||||
3 => 'Duplicate Interface Name (3)',
|
3 => 'Duplicate Interface Name (3)',
|
||||||
4 => 4,
|
4 => 4,
|
||||||
|
5 => 5,
|
||||||
|
6 => 6,
|
||||||
|
7 => 7,
|
||||||
|
8 => 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
can_ok($test->{info}, 'interfaces');
|
can_ok($test->{info}, 'interfaces');
|
||||||
cmp_deeply($test->{info}->interfaces(),
|
cmp_deeply($test->{info}->interfaces(),
|
||||||
$expected_data, 'Call to interfaces() removes duplicates');
|
$expected_data, 'Call to interfaces() removes duplicates and cleans up');
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -50,11 +50,15 @@ sub setup : Tests(setup) {
|
|||||||
'_i_index' => 1,
|
'_i_index' => 1,
|
||||||
'_i_description' => 1,
|
'_i_description' => 1,
|
||||||
'store' => {
|
'store' => {
|
||||||
'i_index' => {1 => 1, 2 => 2, 3 => 3, 4 => 4},
|
'i_index' => { map {($_ => $_)} (1 .. 8) },
|
||||||
'i_description' => {
|
'i_description' => {
|
||||||
1 => 'Unique Interface Name',
|
1 => 'Unique Interface Name',
|
||||||
2 => 'Duplicate Interface Name',
|
2 => 'Duplicate Interface Name',
|
||||||
3 => 'Duplicate Interface Name'
|
3 => 'Duplicate Interface Name',
|
||||||
|
4 => "\0",
|
||||||
|
5 => "\0",
|
||||||
|
6 => " \0",
|
||||||
|
7 => "\0 ",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -69,11 +73,15 @@ sub duplicates : Tests(2) {
|
|||||||
2 => 'Duplicate Interface Name (2)',
|
2 => 'Duplicate Interface Name (2)',
|
||||||
3 => 'Duplicate Interface Name (3)',
|
3 => 'Duplicate Interface Name (3)',
|
||||||
4 => 4,
|
4 => 4,
|
||||||
|
5 => 5,
|
||||||
|
6 => 6,
|
||||||
|
7 => 7,
|
||||||
|
8 => 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
can_ok($test->{info}, 'interfaces');
|
can_ok($test->{info}, 'interfaces');
|
||||||
cmp_deeply($test->{info}->interfaces(),
|
cmp_deeply($test->{info}->interfaces(),
|
||||||
$expected_data, 'Call to interfaces() removes duplicates');
|
$expected_data, 'Call to interfaces() removes duplicates and cleans up');
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
Reference in New Issue
Block a user