Type/Plugin/Unix.pm

filter: Statementstmt 100% 24 / 24 Branchbran 75.0% 9 / 12 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 3 totaltotal 79.5% 39 / 49 CC 9 SCAR 14.4
CC
9
Cov
88%
fstype
6.0
diagnose
3.2
new
2.0
CRAP 4.2
« Type/Plugin/Windows.pm ↑ Summary Type.pm »
1 package Filesys::Type::Plugin::Unix;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 our $VERSION = 0.02;
5 1 our ($df,$mounted,$err);
6  
7 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
8 1 my $pkg = shift;
9  
10 #Check we really are on a Unix type operating system
11 1 ▶ return undef unless -d '/etc';
Branch: 1 branch
BranchTrueFalseTotal
unless -d "/etc" 0 1 1
12  
13 1 bless {}, $pkg;
14 }
15  
16 5 ▶sub fstype {
Subroutine fstype: called CC=6 SCAR=18.0
Pod undocumented
17 5 my ($self,$path) = @_;
18 5 $err = '';
19  
20 5 $df = `df $path 2>/dev/null`;
21 5 ▶ $err = 'df command failed' unless $df;
Branch: 1 branch
BranchTrueFalseTotal
unless $Filesys::Type::Plugin::Unix::df 2 3 5
22 5 $mounted = `mount 2>/dev/null`; # Does not need root
23 5 ▶ $err = 'mount command failed' unless $df;
Branch: 1 branch
BranchTrueFalseTotal
unless $Filesys::Type::Plugin::Unix::df 2 3 5
24 5 ▶ return undef if $err;
Branch: 1 branch
BranchTrueFalseTotal
if $Filesys::Type::Plugin::Unix::err 2 3 5
25  
26 3 my ($mounted_fs) = $df =~ /\d\%\s(\S+)/;
27 3 ▶ $err = 'df output did not parse' unless $mounted_fs;
Branch: 1 branch
BranchTrueFalseTotal
unless $mounted_fs 0 3 3
28 3 ▶ return undef if $err;
Branch: 1 branch
BranchTrueFalseTotal
if $Filesys::Type::Plugin::Unix::err 0 3 3
29
30 3 my ($fstype) = $mounted =~ /on\s$mounted_fs\stype\s(\w+)/;
31 3 $fstype;
32 }
33  
34 1 ▶sub diagnose {
Subroutine diagnose: called CC=3 SCAR=11.7
Pod undocumented
35 1 ▶ $df ||= 'undef';
Condition50%1/2
$Filesys::Type::Plugin::Unix::df ||= "undef"
l!l
01
MC/DC0%0/1
$Filesys::Type::Plugin::Unix::df ||= "undef"
$Filesys::Type::Plugin::Unix::df
Truth table50%1/2
A
A= $Filesys::Type::Plugin::Unix::df
Aresult
11
00
36 1 ▶ $mounted ||= 'undef';
Condition50%1/2
$Filesys::Type::Plugin::Unix::mounted ||= "undef"
l!l
10
MC/DC0%0/1
$Filesys::Type::Plugin::Unix::mounted ||= "undef"
$Filesys::Type::Plugin::Unix::mounted
Truth table50%1/2
A
A= $Filesys::Type::Plugin::Unix::mounted
Aresult
11
00
37 1 <<END;
38 $err
39  
40 df command returned: $df
41  
42 mount command returned: $mounted
43  
44 END
45 }
46 1 1;
47  
« Type/Plugin/Windows.pm ↑ Summary Type.pm »