Any/Test/Backend/Remote.pm

filter: Statementstmt 44.6% 21 / 47 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 85.7% 6 / 7 Podpod n/a totaltotal 36.9% 27 / 73 CC 15 SCAR 39.0
CC
15
Cov
32%
_is_localhost
90.0
_start_and_check
31.3
BEGIN
1.0
CRAP 49.2
« Any/OS/AnyEvent.pm ↑ Summary Any/_Base.pm »
1 package Net::SSH::Any::Test::Backend::Remote;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Net::SSH::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Net::SSH::Any::Constants qw(SSHA_BACKEND_ERROR);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use parent 'Net::SSH::Any::Test::Backend::_Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶sub _start_and_check {
Subroutine _start_and_check: called CC=7 SCAR=34.4
12 1 my $tssh = shift;
13  
14 1 for my $uri (@{$tssh->{uris}}) {
15 0 ▶ $tssh->_check_and_set_uri($uri) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$tssh->_check_and_set_uri($uri) and return 1 0 0 0
16 0 for my $key_path (@{$tssh->{key_paths}}) {
17 0 my $uri2 = Net::SSH::Any::URI->new($uri->uri);
18 0 $uri2->set(password => ());
19 0 $uri2->set(key_path => $key_path);
20 0 ▶ $tssh->_check_and_set_uri($uri2) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$tssh->_check_and_set_uri($uri2) and return 1 0 0 0
21 }
22 0 for my $password (@{$tssh->{passwords}}) {
23 0 my $uri2 = Net::SSH::Any::URI->new($uri->uri);
24 0 $uri2->set(password => $password);
25 0 $uri2->set(key_path => ());
26 0 ▶ $tssh->_check_and_set_uri($uri2) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$tssh->_check_and_set_uri($uri2) and return 1 0 0 0
27 }
28 }
29 1 $tssh->_set_error(SSHA_BACKEND_ERROR, "SSH server not found");
30 ()
31 1 }
32  
33 0 ▶sub _is_localhost {
Subroutine _is_localhost: not called CC=9 SCAR=45.0
34 0 my ($tssh, $ssh) = @_;
35 0 my $fn = $tssh->_backend_wfile(sprintf("localhost-check-%06d", int rand 1000000));
36 0 $fn = File::Spec->rel2abs($fn);
37 0 ▶ open my($fh), '>', $fn or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $fn or return 0 0 0
38 0 print $fh "hello!\n";
39 0 ▶ close $fh or return;
Branch: 1 branch
BranchTrueFalseTotal
close $fh or return 0 0 0
40  
41 0 ▶ $ssh //= $tssh->_new_ssh_client($tssh->uri) // return;
Condition0%0/4
$ssh //= $tssh->_new_ssh_client($tssh->uri) // (return)
l!l
00
$tssh->_new_ssh_client($tssh->uri) // (return)
l!l
00
MC/DC0%0/1
$ssh //= $tssh->_new_ssh_client($tssh->uri) // (return)
$ssh
Truth table0%0/2
A
A= $ssh
Aresult
11
00
42 0 my %rfn = ( $fn => 1,
43 $tssh->_os_unix_path($fn) => 1 );
44 0 for my $rfn (keys %rfn) {
45 0 ▶ return 1 if $ssh->scp_get_content($rfn) =~ /hello/;
Branch: 1 branch
BranchTrueFalseTotal
if $ssh->scp_get_content($rfn) =~ /hello/ 0 0 0
46 0 for my $cmd ("cat $rfn",
47 "type $rfn") {
48 0 ▶ return 1 if $ssh->capture({stderr_discard => 1}, $cmd) =~ /hello/;
Branch: 1 branch
BranchTrueFalseTotal
if $ssh->capture({"stderr_discard", 1}, $cmd) =~ /hello/ 0 0 0
49 }
50 }
51 0 0;
52 }
53  
54 1 1;
« Any/OS/AnyEvent.pm ↑ Summary Any/_Base.pm »