works and now testable

This commit is contained in:
Zane C. B-H 2019-07-28 04:25:31 -05:00
parent 5a93d09655
commit c0035a1149
2 changed files with 33 additions and 0 deletions

View File

@ -118,6 +118,12 @@ sub lsof_to_nc_objects{
$args->{local_host}=$ip;
$args->{local_port}=$port;
$args->{state}='';
if ( defined( $line_split[8] ) ){
$args->{state}=$line_split[8];
$args->{state}=~s/[\(\)]//;
}
push( @nc_objects, Net::Connection->new( $args ) );
$line_int++;

View File

@ -0,0 +1,27 @@
#!perl
use 5.006;
use strict;
use warnings;
use Test::More;
my $extra_tests=0;
BEGIN {
use_ok( 'Net::Connection::lsof' ) || print "Bail out!\n";
}
my $output_raw=`lsof -i UDP -i TCP -n -l +c 19 -P`;
if ( $@ ne 0 ){
$extra_tests++;
my $worked=0;
eval{
my @nc_objects=&lsof_to_nc_objects;
$worked=1;
};
ok( $worked eq '1', 'lsof_to_nc_objects') or diag("lsof_to_nc_objects died with ".$@);
}
my $tests_ran=1+$extra_tests;
done_testing($tests_ran);