| 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
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 42 | 0 | my $uid = get_uid( $stats->{'owner'} ); | |||||||||||||||||||
| 43 | 0 | ▶ | my $result = defined $uid ? $uid == $stat{'uid'} : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 47 | unless defined $uid; | ||||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | ▶ | if ( defined( $stats->{'group'} ) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 0 | my $gid = get_gid( $stats->{'group'} ); | |||||||||||||||||||
| 52 | 0 | ▶ | my $result = defined $gid ? $gid == $stat{'gid'} : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 56 | unless defined $gid; | ||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 1 | 1; | |||||||||||||||||||