lib/Rex/Test/Base/has_stat.pm

filter: Statementstmt 44.1% 19 / 43 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 50.0% 1 / 2 totaltotal 36.1% 26 / 72 CC 9 SCAR 36.1
CC
9
Cov
32%
run_test
72.0
new
6.0
BEGIN
1.0
CRAP 37.1
« lib/Rex/Cloud/OpenStack.pm ↑ Summary lib/Rex/Commands/Sysctl.pm »
1 #
2 # (c) Robert Abraham <robert@adeven.com>
3 #
4  
5 package Rex::Test::Base::has_stat;
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 -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use base qw(Rex::Test::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Rex::Commands::Fs;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Rex::Commands::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
18 0 my $that = shift;
19 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
20 0 my $self = {@_};
21  
22 0 bless( $self, $proto );
23  
24 0 my ( $pkg, $file ) = caller(0);
25  
26 0 return $self;
27 }
28  
29 0 ▶sub run_test {
Subroutine run_test: not called CC=8 SCAR=42.8
Pod undocumented
30 0 my ( $self, $path, $stats ) = @_;
31  
32 0 my %stat;
33 0 eval { %stat = stat $path; };
34  
35 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
36 0 $self->ok( 0, "has_stat: cannot stat $path." );
37 0 $self->diag($@);
38 0 return;
39 }
40  
41 0 ▶ if ( defined( $stats->{'owner'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stats->{"owner"}) 0 0 0
42 0 my $uid = get_uid( $stats->{'owner'} );
43 0 ▶ my $result = defined $uid ? $uid == $stat{'uid'} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $uid ? : 0 0 0
44  
45 0 $self->ok( $result, "Owner of $path is $stats->{'owner'}" );
46 0 ▶ $self->diag("has_stat: get_uid failed for $stats->{'owner'}.")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uid 0 0 0
47 unless defined $uid;
48 }
49  
50 0 ▶ if ( defined( $stats->{'group'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stats->{"group"}) 0 0 0
51 0 my $gid = get_gid( $stats->{'group'} );
52 0 ▶ my $result = defined $gid ? $gid == $stat{'gid'} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $gid ? : 0 0 0
53  
54 0 $self->ok( $result, "Group of $path is $stats->{'group'}" );
55 0 ▶ $self->diag("has_stat: get_gid failed for $stats->{'group'}.")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gid 0 0 0
56 unless defined $gid;
57 }
58 }
59  
60 1 1;
« lib/Rex/Cloud/OpenStack.pm ↑ Summary lib/Rex/Commands/Sysctl.pm »