Modinfo.pm

filter: Statementstmt 27.5% 11 / 40 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 33.3% 2 / 6 Podpod 75.0% 3 / 4 totaltotal 28.0% 16 / 57 CC 6 SCAR 27.3
CC
6
Cov
24%
new
30.0
showModule
6.0
listModule
2.0
CRAP 15.3
↑ Summary testModinfo.pl »
1 #!/usr/bin/perl -w
2  
3 package Solaris::Modinfo;
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require Exporter;
8 1 require DynaLoader;
9  
10 1 ▶use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 @ISA = qw(Exporter DynaLoader);
13  
14 1 $VERSION = 0.1;
15  
16 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
17 0 my($proto, @modinfo) = shift;
18 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
19 0 my $self = { };
20  
21 0 @modinfo = qx(modinfo);
22 0 $self->{_private}{numModule} = 0;
23  
24 0 for (@modinfo) {
25 0 chomp;
26 0 s#^\s+##;
27  
28 0 ▶ next if ($_ =~ /^Id/g);
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ /^Id/g 0 0 0
29 0 my(@line) = split(/\s+/, $_);
30  
31 0 my $id = $self->{_private}{numModule};
32  
33 0 foreach my $info ("Id", "Loadaddr", "Size", "Info", "Rev") {
34 0 $self->{_modinfo}{$id}{$info} = shift(@line);
35 }
36  
37 0 $self->{_modinfo}{$id}{ModuleName} = join(" ", @line);
38 0 $self->{_private}{numModule}++;
39 }
40 0 bless $self, $class;
41
42 0 return $self;
43 }
44  
45 0 ▶sub listModule {
Subroutine listModule: not called CC=1 SCAR=6.9
Pod documented
46 0 my($self)= @_;
47  
48 0 return $self->{_modinfo};
49 }
50  
51 0 ▶sub countModule {
Subroutine countModule: not called CC=1 SCAR=6.9
Pod documented
52 0 my($self)= @_;
53  
54 0 return $self->{_private}{numModule};
55 }
56  
57 0 ▶sub showModule {
Subroutine showModule: not called CC=2 SCAR=17.9
Pod documented
58 0 my($self) = @_;
59 0 my(@mod_t);
60  
61 0 for (sort { $a <=> $b } keys %{ $self->{_modinfo} }) {
62 push(@mod_t, $self->{_modinfo}{$_}{Id}, $self->{_modinfo}{$_}{Loadaddr},
63 $self->{_modinfo}{$_}{Size}, $self->{_modinfo}{$_}{Info},
64 0 $self->{_modinfo}{$_}{Rev}, $self->{_modinfo}{$_}{ModuleName});
65 0 write;
66 0 undef @mod_t;
67 }
68  
69 format STDOUT =
70 @<<<<<@<<<<<<<<<<<@<<<<<<<@<<<<@<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
71 $mod_t[0], $mod_t[1], $mod_t[2], $mod_t[3], $mod_t[4], $mod_t[5]
72 .
73  
74 }
75  
76 1 1;
77  
78 =head1 NAME
79  
80 Solaris::Modinfo - Perl module providing object oriented interface to modinfo (display information about Solaris loaded kernel modules)
81  
82 =head1 SYNOPSIS
83  
84 use Solaris::Modinfo;
85  
86 my $module = Solaris::Modinfo->new();
87 my $modinfo = $module->listModule();
88  
89 print "Number of modules : ", $module->countModule(), "\n";
90  
91 map {
92 print $modinfo->{$_}{Id}, " ",
93 $modinfo->{$_}{Loadaddr}, " ",
94 $modinfo->{$_}{Size}, " ",
95 $modinfo->{$_}{Info}, " ",
96 $modinfo->{$_}{Rev}, " ",
97 $modinfo->{$_}{ModuleName}, "\n";
98 }(keys %{ $modinfo });
99  
100 =head1 DESCRIPTION
101  
102 This module provides an object oriented interface to the module informations. The implementation attempts to display informations about Solaris loaded kernel modules.
103  
104 =head2 METHODS
105  
106 =item listModule
107  
108 Provide a reference to a hash of the modinfo parameters.
109  
110 =item countModule
111  
112 Display the number of kernel module loaded.
113  
114 =item showModule
115  
116 Display the information of kernel module loaded.
117  
118 =head1 AUTHOR
119  
120 Stephane Chmielewski <snck@free.fr>
121  
122 =head1 COPYRIGHT
123  
124 Copyright (C) 2006 Stephane Chmielewski. All rights reserved.
125 This program is free software; you can redistribute it and/or modify it
126 under the same terms as Perl itself.
127  
128 =cut
↑ Summary testModinfo.pl »