line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::Database; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Test::Smoke::Database - Add / parse /display perl reports smoke database |
4
|
|
|
|
|
|
|
# Copyright 2003 A.Barbet alian@alianwebserver.com. All rights reserved. |
5
|
|
|
|
|
|
|
# $Date: 2004/04/19 17:48:23 $ |
6
|
|
|
|
|
|
|
# $Log: Database.pm,v $ |
7
|
|
|
|
|
|
|
# Revision 1.18 2004/04/19 17:48:23 alian |
8
|
|
|
|
|
|
|
# update to 1.17 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Revision 1.17 2004/04/14 22:37:47 alian |
11
|
|
|
|
|
|
|
# change url for eg of cgi |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Revision 1.16 2003/11/07 17:42:22 alian |
14
|
|
|
|
|
|
|
# Avoid warnings when create graph |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# Revision 1.15 2003/09/16 15:41:50 alian |
17
|
|
|
|
|
|
|
# - Update parsing to parse 5.6.1 report |
18
|
|
|
|
|
|
|
# - Change display for lynx |
19
|
|
|
|
|
|
|
# - Add top smokers |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# Revision 1.14 2003/08/19 10:37:24 alian |
22
|
|
|
|
|
|
|
# - FORMAT OF DATABASE UPDATED ! (two cols added, one moved). |
23
|
|
|
|
|
|
|
# - Add a 'version' field to filter/parser (Eg: All perl-5.8.1 report) |
24
|
|
|
|
|
|
|
# - Use the field 'date' into filter/parser (Eg: All report after 07/2003) |
25
|
|
|
|
|
|
|
# - Add an author field to parser, and a smoker HTML page about recent |
26
|
|
|
|
|
|
|
# smokers and their available config. |
27
|
|
|
|
|
|
|
# - Change how nbte (number of failed tests) is calculate |
28
|
|
|
|
|
|
|
# - Graph are done by month, no longuer with patchlevel |
29
|
|
|
|
|
|
|
# - Only rewrite cc if gcc. Else we lost solaris info |
30
|
|
|
|
|
|
|
# - Remove ccache info for have less distinct compiler |
31
|
|
|
|
|
|
|
# - Add another report to tests |
32
|
|
|
|
|
|
|
# - Update FAQ.pod for last Test::Smoke version |
33
|
|
|
|
|
|
|
# - Save only wanted headers for each nntp articles (and save From: field). |
34
|
|
|
|
|
|
|
# - Move away last varchar field from builds to data |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
3
|
|
110088
|
use Carp; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
321
|
|
38
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
128
|
|
39
|
3
|
|
|
3
|
|
18
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
276
|
|
40
|
3
|
|
|
3
|
|
18587
|
use DBI; |
|
3
|
|
|
|
|
97177
|
|
|
3
|
|
|
|
|
373
|
|
41
|
3
|
|
|
3
|
|
3935
|
use News::NNTPClient; |
|
3
|
|
|
|
|
52938
|
|
|
3
|
|
|
|
|
119
|
|
42
|
3
|
|
|
3
|
|
496184
|
use Data::Dumper; |
|
3
|
|
|
|
|
56939
|
|
|
3
|
|
|
|
|
300
|
|
43
|
3
|
|
|
3
|
|
2642
|
use Test::Smoke::Database::Graph; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
228
|
|
44
|
3
|
|
|
3
|
|
2566
|
use Test::Smoke::Database::DB; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
155
|
|
45
|
3
|
|
|
3
|
|
2522
|
use Test::Smoke::Database::Display; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
180
|
|
46
|
3
|
|
|
3
|
|
3056
|
use Test::Smoke::Database::Parsing; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
205
|
|
47
|
3
|
|
|
3
|
|
200
|
use Carp qw(cluck); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
157
|
|
48
|
3
|
|
|
3
|
|
15
|
use File::Basename; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
5145
|
|
49
|
|
|
|
|
|
|
require Exporter; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
52
|
|
|
|
|
|
|
@EXPORT = qw(); |
53
|
|
|
|
|
|
|
$VERSION = '1.17'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $limite = 18600; |
56
|
|
|
|
|
|
|
#$limite = 0; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
59
|
|
|
|
|
|
|
# new |
60
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
61
|
|
|
|
|
|
|
sub new($$) { |
62
|
1
|
|
|
1
|
1
|
642
|
my $class = shift; |
63
|
1
|
|
|
|
|
5
|
my $self = {}; |
64
|
1
|
|
|
|
|
3
|
bless $self, $class; |
65
|
1
|
|
50
|
|
|
19
|
$self->{opts} = shift || {}; |
66
|
1
|
|
50
|
|
|
15
|
my $driver = "DBI:mysql:database=".($self->{opts}->{database} || 'test'). |
67
|
|
|
|
|
|
|
";host=localhost;port=3306"; |
68
|
1
|
50
|
|
|
|
10
|
if (!$self->{opts}->{no_dbconnect}) { |
69
|
0
|
|
0
|
|
|
0
|
$self->{DBH} = DBI->connect($driver, |
70
|
|
|
|
|
|
|
$self->{opts}->{user}, |
71
|
|
|
|
|
|
|
$self->{opts}->{password} || undef) |
72
|
|
|
|
|
|
|
|| die "Can't connect to Mysql:$driver:$!\n"; |
73
|
|
|
|
|
|
|
} |
74
|
1
|
50
|
|
|
|
6
|
if (defined($self->{opts}->{limit})) { |
75
|
0
|
0
|
|
|
|
0
|
$self->{opts}->{limit} = 0 if ( $self->{opts}->{limit} eq 'All'); |
76
|
0
|
|
|
|
|
0
|
$limite = $self->{opts}->{limit}; |
77
|
1
|
|
|
|
|
5
|
} else { $limite = 0; } |
78
|
1
|
|
|
|
|
14
|
$self->{DB} = new Test::Smoke::Database::DB($self); |
79
|
1
|
|
|
|
|
15
|
$self->{HTML} = new Test::Smoke::Database::Display($self); |
80
|
1
|
50
|
|
|
|
7
|
print scalar(localtime), |
81
|
|
|
|
|
|
|
": New run with Test::Smoke::Database version $VERSION\n" |
82
|
|
|
|
|
|
|
if ($self->{opts}->{verbose}); |
83
|
1
|
|
|
|
|
5
|
return $self; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
87
|
|
|
|
|
|
|
# db |
88
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
89
|
0
|
|
|
0
|
0
|
0
|
sub db(\%) { return $_[0]->{DB}; } |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
92
|
|
|
|
|
|
|
# HTML |
93
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
94
|
2
|
|
|
2
|
0
|
872
|
sub HTML(\%) { return $_[0]->{HTML}; } |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
98
|
|
|
|
|
|
|
# build_graph |
99
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
100
|
|
|
|
|
|
|
sub build_graph(\%) { |
101
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
102
|
0
|
0
|
|
|
|
|
print scalar(localtime),": Create graph\n" |
103
|
|
|
|
|
|
|
if ($self->{opts}->{verbose}); |
104
|
0
|
|
|
|
|
|
eval("use GD::Graph::mixed"); |
105
|
0
|
0
|
|
|
|
|
if ($@) { |
106
|
0
|
0
|
|
|
|
|
print scalar(localtime), |
107
|
|
|
|
|
|
|
": You don't seem to have GD::Graph, aborted graph\n" |
108
|
|
|
|
|
|
|
if ($self->{opts}->{verbose}); |
109
|
0
|
|
|
|
|
|
return; |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
|
|
|
my $c = new CGI; |
112
|
|
|
|
|
|
|
# Last 50 smoke |
113
|
0
|
|
|
|
|
|
my $last50 = $self->db->last50; |
114
|
|
|
|
|
|
|
# Begin, perl-5.9, last 50 smoke |
115
|
0
|
|
|
|
|
|
my %limit = (0 =>'Since smoke 11613', |
116
|
|
|
|
|
|
|
17500=>'Perl 5.9', |
117
|
|
|
|
|
|
|
$last50=>'Last 50 smoke'); |
118
|
0
|
|
|
|
|
|
my %limit2 = %limit; |
119
|
0
|
|
|
|
|
|
$limit2{cpan}= 'CPAN modules'; |
120
|
0
|
|
|
|
|
|
$limit2{"last50"}=$limit2{$last50}; |
121
|
0
|
|
|
|
|
|
delete $limit2{$last50}; |
122
|
0
|
|
|
|
|
|
foreach my $mt (keys %limit) { |
123
|
0
|
|
|
|
|
|
my $mtx = $mt; |
124
|
0
|
0
|
|
|
|
|
$mtx = "last50" if ($mt == $last50); |
125
|
0
|
|
|
|
|
|
my $graph = new Test::Smoke::Database::Graph($self->{DBH}, $self,$mt, $mtx); |
126
|
0
|
|
|
|
|
|
$graph->percent_configure(); |
127
|
0
|
|
|
|
|
|
$graph->percent_configure_all(); |
128
|
0
|
|
|
|
|
|
$graph->configure_per_os(); |
129
|
0
|
|
|
|
|
|
$graph->smoke_per_os(); |
130
|
0
|
|
|
|
|
|
$graph->configure_per_smoke(); |
131
|
0
|
|
|
|
|
|
$graph->os_by_smoke(); |
132
|
0
|
|
|
|
|
|
$graph->success_by_os(); |
133
|
0
|
|
|
|
|
|
$graph->create_html($mtx, \%limit2, $c); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my $graph = new Test::Smoke::Database::Graph($self->{DBH}, $self,undef, "cpan"); |
137
|
0
|
0
|
|
|
|
|
$graph->stats_cpan() && |
138
|
|
|
|
|
|
|
$graph->create_html("cpan", \%limit2, $c); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
143
|
|
|
|
|
|
|
# rename_rpt |
144
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
145
|
|
|
|
|
|
|
sub rename_rpt { |
146
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
147
|
0
|
|
|
|
|
|
my $nb = 0; |
148
|
0
|
0
|
|
|
|
|
print scalar(localtime),": Rename report with his nntp id\n" |
149
|
|
|
|
|
|
|
if ($self->{opts}->{verbose}); |
150
|
0
|
|
|
|
|
|
foreach my $f (glob($self->{opts}->{dir}."/*.rpt")) { |
151
|
0
|
|
|
|
|
|
my $e=`grep 'for [ 1234567890.]*patch' $f`; |
152
|
0
|
0
|
|
|
|
|
if ($e=~/for [\d\.]* ?patch (\d+)/) { |
153
|
0
|
0
|
|
|
|
|
if (-e "$f.$1") { unlink($f); } |
|
0
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
else { |
155
|
0
|
0
|
|
|
|
|
print "Rename $f $1\n" if ($self->{opts}->{debug}); |
156
|
0
|
|
|
|
|
|
`mv $f $f.$1`; |
157
|
0
|
|
|
|
|
|
$nb++; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
0
|
|
|
|
|
|
return $nb; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
165
|
|
|
|
|
|
|
# suck_ng |
166
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
167
|
|
|
|
|
|
|
sub suck_ng { |
168
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
169
|
0
|
|
|
|
|
|
my @good = qw!From Date Subject Return-Path!; |
170
|
0
|
0
|
|
|
|
|
print scalar(localtime),": Suck newsgroup on $self->{opts}->{nntp_server}\n" |
171
|
|
|
|
|
|
|
if ($self->{opts}->{verbose}); |
172
|
|
|
|
|
|
|
# Find last id on dir |
173
|
0
|
|
|
|
|
|
my $max=0; |
174
|
0
|
|
|
|
|
|
my @l = glob($self->{opts}->{dir}."/*"); |
175
|
0
|
0
|
0
|
|
|
|
foreach (@l) { $max=$1 if (/\/(\d*)\.rpt/ && $1 > $max); } |
|
0
|
|
|
|
|
|
|
176
|
0
|
0
|
|
|
|
|
print "NNTP max id is $max ($#l files in $self->{opts}->{dir})\n" |
177
|
|
|
|
|
|
|
if ($self->{opts}->{debug}); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Connect on ng |
180
|
0
|
|
|
|
|
|
my $c = new News::NNTPClient($self->{opts}->{nntp_server}); |
181
|
0
|
0
|
|
|
|
|
return undef if (!$c->ok); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# Fetch last - first |
184
|
0
|
|
|
|
|
|
my ($first, $last) = ($c->group("perl.daily-build.reports")); |
185
|
|
|
|
|
|
|
#print "Max:$max first:$first last:$last\n"; |
186
|
0
|
0
|
|
|
|
|
if ($max) { |
187
|
0
|
0
|
|
|
|
|
if ($max == $last) { |
188
|
0
|
0
|
|
|
|
|
print scalar(localtime),": No new report on perl.daily-build.reports\n" |
189
|
|
|
|
|
|
|
if ($self->{opts}->{verbose}); |
190
|
0
|
|
|
|
|
|
$self->rename_rpt(); |
191
|
0
|
|
|
|
|
|
return; |
192
|
|
|
|
|
|
|
} |
193
|
0
|
|
|
|
|
|
else { $first = $max; } |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
while( $first <= $last) { |
197
|
0
|
0
|
|
|
|
|
open(F,">$self->{opts}->{dir}/$first.rpt") |
198
|
|
|
|
|
|
|
or die "Can't create $self->{opts}->{dir}/$first.rpt:$!\n"; |
199
|
0
|
|
|
|
|
|
my @buf = $c->article($first); |
200
|
0
|
|
|
|
|
|
my ($ok,$isreport,$entete,$buf)=(0,1,1); |
201
|
0
|
|
|
|
|
|
foreach (@buf) { |
202
|
0
|
0
|
|
|
|
|
if (/In-Reply-To/) { $isreport=0; last;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
if (m!^$!) { $entete=0; } |
|
0
|
|
|
|
|
|
|
204
|
0
|
0
|
|
|
|
|
if ($entete) { |
205
|
0
|
|
|
|
|
|
foreach my $e (@good) { |
206
|
0
|
0
|
|
|
|
|
print F $_ if (/^$e/); |
207
|
|
|
|
|
|
|
} |
208
|
0
|
|
|
|
|
|
} else { print F $_; } |
209
|
|
|
|
|
|
|
} |
210
|
0
|
|
|
|
|
|
close(F); |
211
|
0
|
0
|
|
|
|
|
if (!$isreport) { unlink("$first.rpt"); } |
|
0
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
$first++; |
213
|
|
|
|
|
|
|
} |
214
|
0
|
|
|
|
|
|
$self->rename_rpt(); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
218
|
|
|
|
|
|
|
# parse_import |
219
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
220
|
|
|
|
|
|
|
sub parse_import { |
221
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
222
|
0
|
|
|
|
|
|
Test::Smoke::Database::Parsing::parse_import($self); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
__END__ |