line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ProjectBuilder::Log::Item; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Each PB::Log::Item represents one machine |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
937
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# the *matches represents strings, which a line must contain, to be recognized as a corresponding found |
8
|
|
|
|
|
|
|
# the *exludes can be used to exclude a string (if the string contains a *match and a *exclude, the line is ignored) |
9
|
|
|
|
|
|
|
# the name is by default the name of the vm (e.g. ubuntu-10.04-i386) |
10
|
|
|
|
|
|
|
sub new { |
11
|
|
|
|
|
|
|
# contains the object name (here PBLog) |
12
|
0
|
|
|
0
|
0
|
|
my $object = shift; |
13
|
0
|
|
0
|
|
|
|
my $vmname = shift || ""; |
14
|
0
|
|
0
|
|
|
|
my $log = shift || ""; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $self = {}; |
17
|
|
|
|
|
|
|
# $ref should point to an object of type $object |
18
|
0
|
|
|
|
|
|
bless($self, $object); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# array of strings, which are indicating errors or warnings (case insensitive) |
21
|
0
|
|
|
|
|
|
$self->{'errormatches'} = []; |
22
|
0
|
|
|
|
|
|
$self->{'warningmatches'} = []; |
23
|
|
|
|
|
|
|
# array of strings, which are excluded from error lines (case insensitive) |
24
|
0
|
|
|
|
|
|
$self->{'errorexcludes'} = []; |
25
|
0
|
|
|
|
|
|
$self->{'warningexcludes'} = []; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
push(@{$self->{'errormatches'}}, "error"); |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
push(@{$self->{'errormatches'}}, "fehler"); |
|
0
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
push(@{$self->{'warningmatches'}}, "warning"); |
|
0
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
push(@{$self->{'warningmatches'}}, "warnung"); |
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# init default values |
34
|
0
|
|
|
|
|
|
$self->setName($vmname); |
35
|
0
|
|
|
|
|
|
$self->setLog($log); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return($self); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#set's the name |
41
|
|
|
|
|
|
|
sub setName { |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
0
|
|
0
|
|
|
|
my $vmname = shift || ""; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$self->{'vmname'} = $vmname; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# returns the name |
49
|
|
|
|
|
|
|
sub name { |
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $self->{'vmname'}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# set's the log and calls the analyzer (parseLog()) |
56
|
|
|
|
|
|
|
sub setLog { |
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
58
|
0
|
|
0
|
|
|
|
my $log = shift || ""; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->{'qawarnings'} = []; |
61
|
0
|
|
|
|
|
|
$self->{'qaerrors'} = []; |
62
|
0
|
|
|
|
|
|
$self->{'warnings'} = []; |
63
|
0
|
|
|
|
|
|
$self->{'errors'} = []; |
64
|
0
|
|
|
|
|
|
$self->{'log'} = $log; |
65
|
0
|
|
|
|
|
|
$self->parseLog; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# returns the "raw" log text |
69
|
|
|
|
|
|
|
sub log { |
70
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return $self->{'log'}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# returns the number of warnings and errors reported by lintian or rpmlint |
76
|
|
|
|
|
|
|
sub numQaIssues { |
77
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return scalar($self->qaIssues); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# returns the issues itself |
83
|
|
|
|
|
|
|
sub qaIssues { |
84
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
85
|
0
|
|
|
|
|
|
my @result = $self->qaErrors; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
push(@result, $self->qaWarnings); |
88
|
0
|
|
|
|
|
|
return @result; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#returns only the warnings |
92
|
|
|
|
|
|
|
sub qaWarnings { |
93
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return @{$self->{'qawarnings'}}; |
|
0
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# returns only the errors |
99
|
|
|
|
|
|
|
sub qaErrors { |
100
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return @{$self->{'qaerrors'}}; |
|
0
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# returns the number of compile errors |
106
|
|
|
|
|
|
|
# or better, all other than lintian and rpmlint |
107
|
|
|
|
|
|
|
sub numErrors { |
108
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return scalar($self->errors); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# returns the errors itself |
114
|
|
|
|
|
|
|
sub errors { |
115
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return @{$self->{'errors'}}; |
|
0
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# same for warnings |
121
|
|
|
|
|
|
|
sub numWarnings { |
122
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
return scalar($self->warnings); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# same for warnings |
128
|
|
|
|
|
|
|
sub warnings { |
129
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
return @{$self->{'warnings'}}; |
|
0
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# private part |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# parses the log |
137
|
|
|
|
|
|
|
sub parseLog { |
138
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
my @lines = split("\n", $self->{'log'}); |
141
|
0
|
|
|
|
|
|
foreach my $line (@lines) { |
142
|
|
|
|
|
|
|
# check for lintian or rpmlint errors |
143
|
0
|
0
|
|
|
|
|
if ($line =~ m/^W:/) { |
|
|
0
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
push(@{$self->{'qawarnings'}}, $line); |
|
0
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
} elsif ($line =~ m/^E:/) { |
146
|
0
|
|
|
|
|
|
push(@{$self->{'qaerrors'}}, $line); |
|
0
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
} else { |
148
|
|
|
|
|
|
|
# error detect |
149
|
0
|
|
|
|
|
|
my $iserror = 0; |
150
|
0
|
|
|
|
|
|
foreach my $errormatch (@{$self->{'errormatches'}}) { |
|
0
|
|
|
|
|
|
|
151
|
0
|
0
|
|
|
|
|
if($line =~ m/$errormatch/){ |
152
|
|
|
|
|
|
|
# check wether an exclude is also true |
153
|
0
|
|
|
|
|
|
my $isexcluded = 0; |
154
|
0
|
|
|
|
|
|
foreach my $exclude (@{$self->{'errorexcludes'}}) { |
|
0
|
|
|
|
|
|
|
155
|
0
|
0
|
|
|
|
|
if ($line =~ m/$exclude/) { |
156
|
0
|
|
|
|
|
|
$isexcluded = 1; |
157
|
0
|
|
|
|
|
|
last; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
0
|
0
|
|
|
|
|
if ($isexcluded == 0) { |
161
|
|
|
|
|
|
|
# it is an error and not excluded, so add it to array |
162
|
0
|
|
|
|
|
|
push(@{$self->{'errors'}}, $line); |
|
0
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
$iserror = 1; |
164
|
0
|
|
|
|
|
|
last; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# warning detect |
170
|
0
|
0
|
|
|
|
|
if ($iserror == 0) { |
171
|
0
|
|
|
|
|
|
foreach my $match (@{$self->{'warningmatches'}}) { |
|
0
|
|
|
|
|
|
|
172
|
0
|
0
|
|
|
|
|
if($line =~ m/$match/){ |
173
|
|
|
|
|
|
|
# check wether an exclude is also true |
174
|
0
|
|
|
|
|
|
my $isexcluded = 0; |
175
|
0
|
|
|
|
|
|
foreach my $exclude (@{$self->{'warningexcludes'}}) { |
|
0
|
|
|
|
|
|
|
176
|
0
|
0
|
|
|
|
|
if ($line =~ m/$exclude/) { |
177
|
0
|
|
|
|
|
|
$isexcluded = 1; |
178
|
0
|
|
|
|
|
|
last; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
} |
181
|
0
|
0
|
|
|
|
|
if ($isexcluded == 0) { |
182
|
|
|
|
|
|
|
# it is an error and not excluded, so add it to array |
183
|
0
|
|
|
|
|
|
push(@{$self->{'warnings'}}, $line); |
|
0
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
$iserror = 1; |
185
|
0
|
|
|
|
|
|
last; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
1; |