Mounts.pm

filter: Statementstmt 28.2% 11 / 39 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 28.5% 2 / 7 Podpod 40.0% 2 / 5 totaltotal 20.2% 15 / 74 CC 9 SCAR 33.7
CC
9
Cov
19%
new
56.0
show_mount
12.0
num_mounts
2.0
CRAP 29.0
↑ Summary testMounts.pl »
1 #!/usr/bin/perl -w
2  
3 package Linux::Mounts;
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 require Exporter;
9 1 require DynaLoader;
10  
11 1 our @ISA = qw(Exporter DynaLoader);
12  
13 1 our $VERSION = 0.2;
14  
15 0 ▶sub new {
Subroutine new: not called CC=7 SCAR=40.3
Pod undocumented
16 0 my($proto, $file) = shift;
17 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
18 0 my $self = { };
19  
20 0 ▶ $file ||= '/proc/mounts';
Condition0%0/2
$file ||= "/proc/mounts"
l!l
00
MC/DC0%0/1
$file ||= "/proc/mounts"
$file
Truth table0%0/2
A
A= $file
Aresult
11
00
21  
22 0 ▶ if (-e $file || -f $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $file or -f $file) 0 0 0
Condition0%0/3
-e $file or -f $file
l!l&&r!l&&!r
000
MC/DC0%0/2
-e $file or -f $file
-e $file -f $file
Truth table0%0/3
A or B
A= -e $fileB= -f $file
ABresult
1X1
011
000
23 0 ▶ if (open (MOUNTS, $file)) {
Branch: 1 branch
BranchTrueFalseTotal
if (open MOUNTS, $file) 0 0 0
24 0 $self->{_private}->{num_mounts} = 0;
25 0 ▶ while (<MOUNTS>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline MOUNTS)) 0 0 0
26 0 chomp;
27 0 my $cpt = $self->{_private}->{num_mounts};
28 0 push(@{ $self->{_mountinfo}->[$cpt] }, split(/\s/));
29 0 $self->{_private}->{num_mounts}++;
30 }
31 }
32 0 close(MOUNTS);
33 }
34  
35 0 bless $self, $class;
36
37 0 return $self;
38 }
39  
40 0 ▶sub num_mounts {
Subroutine num_mounts: not called CC=1 SCAR=6.9
Pod documented
41 0 my($self) = @_;
42  
43 0 return $self->{_private}->{num_mounts};
44 }
45  
46 0 ▶sub list_mounts {
Subroutine list_mounts: not called CC=1 SCAR=6.9
Pod documented
47 0 my($self) = @_;
48  
49 0 return $self->{_mountinfo};
50 }
51  
52 0 ▶sub show_mount {
Subroutine show_mount: not called CC=3 SCAR=24.8
Pod undocumented
53 0 my($self) = @_;
54 0 my(@lst_f);
55  
56 0 ▶ for (my $i = 0; $i < $self->{_private}->{num_mounts}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $self->{"_private"}{"num_mounts"}) 0 0 0
57 0 ▶ for (my $j = 0; $j < $#{ $self->{_mountinfo} }; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $#{$$self{"_mountinfo"};}) 0 0 0
58 0 push(@lst_f, $self->{_mountinfo}->[$i][$j]);
59 }
60 0 write;
61 0 undef(@lst_f);
62 }
63  
64 format STDOUT =
65 @<<<<<<<<<<<@<<<<<<<<<<<<<<<<<@<<<<<<<<<<<@<<<<<<@<<@<<<
66 $lst_f[0], $lst_f[1], $lst_f[2], $lst_f[3], $lst_f[4], $lst_f[5]
67 .
68  
69 }
70  
71 0 ▶sub stat_mount {}
Subroutine stat_mount: not called CC=1 SCAR=0.0
Pod undocumented
72  
73 1 1;
74  
75 __END__
↑ Summary testMounts.pl »