lib/Rex/Interface/Exec/SSH.pm

filter: Statementstmt 35.7% 20 / 56 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 0.0% 0 / 2 totaltotal 30.2% 26 / 86 CC 9 SCAR 35.6
CC
9
Cov
27%
exec
72.0
new
6.0
_exec
2.0
CRAP 35.1
« lib/Rex/Pkg/SunOS.pm ↑ Summary blib/lib/Rex/Commands/DB.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Interface::Exec::SSH;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.16.1'; # VERSION
11  
12 1 ▶use Rex::Helper::SSH2;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use File::Basename 'basename';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Rex::Interface::Shell;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 require Rex::Commands;
16  
17 # Use 'parent' is recommended, but from Perl 5.10.1 its in core
18 1 ▶use base 'Rex::Interface::Exec::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
21 0 my $that = shift;
22 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
23 0 my $self = {@_};
24  
25 0 bless( $self, $proto );
26  
27 0 return $self;
28 }
29  
30 0 ▶sub exec {
Subroutine exec: not called CC=8 SCAR=42.8
Pod undocumented
31 0 my ( $self, $cmd, $path, $option ) = @_;
32  
33 0 Rex::Logger::debug("Executing: $cmd");
34  
35 0 Rex::Commands::profiler()->start("exec: $cmd");
36  
37 0 my $shell;
38  
39 0 ▶ if ( $option->{_force_sh} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($option->{'_force_sh'}) { } 0 0 0
40 0 $shell = Rex::Interface::Shell->create("Sh");
41 }
42 else {
43 0 $shell = $self->shell;
44 }
45  
46 0 $shell->set_locale("C");
47 0 $shell->path($path);
48  
49 0 ▶ if ( Rex::Config->get_source_global_profile ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Rex::Config"->get_source_global_profile) 0 0 0
50 0 $shell->source_global_profile(1);
51 }
52  
53 0 ▶ if ( Rex::Config->get_source_profile ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Rex::Config"->get_source_profile) 0 0 0
54 0 $shell->source_profile(1);
55 }
56  
57 0 ▶ if ( exists $option->{env} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $option->{"env"}) 0 0 0
58 0 $shell->set_environment( $option->{env} );
59 }
60  
61 0 my $exec = $shell->exec( $cmd, $option );
62 0 Rex::Logger::debug("SSH/executing: $exec");
63 0 my ( $out, $err ) = $self->_exec( $exec, $option );
64  
65 0 Rex::Commands::profiler()->end("exec: $cmd");
66  
67 0 ▶ Rex::Logger::debug($out) if ($out);
Branch: 1 branch
BranchTrueFalseTotal
if $out 0 0 0
68 0 ▶ if ($err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err) 0 0 0
69 0 Rex::Logger::debug("========= ERR ============");
70 0 Rex::Logger::debug($err);
71 0 Rex::Logger::debug("========= ERR ============");
72 }
73  
74 0 ▶ if (wantarray) { return ( $out, $err ); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
75  
76 0 return $out;
77 }
78  
79 0 ▶sub _exec {
Subroutine _exec: not called CC=1 SCAR=6.9
80 0 my ( $self, $exec, $option ) = @_;
81  
82 # my $callback = $option->{continuous_read} || undef;
83 # $option->{continuous_read} ||= $callback;
84  
85 0 my $ssh = Rex::is_ssh();
86 0 my ( $out, $err ) = net_ssh2_exec( $ssh, $exec, $self, $option );
87  
88 0 return ( $out, $err );
89 }
90  
91 1 1;
« lib/Rex/Pkg/SunOS.pm ↑ Summary blib/lib/Rex/Commands/DB.pm »