line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package TaskForest::Test; |
3
|
|
|
|
|
|
|
|
4
|
95
|
|
|
95
|
|
5946469
|
use strict; |
|
95
|
|
|
|
|
289
|
|
|
95
|
|
|
|
|
6976
|
|
5
|
95
|
|
|
95
|
|
586
|
use warnings; |
|
95
|
|
|
|
|
220
|
|
|
95
|
|
|
|
|
4759
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
95
|
|
|
95
|
|
527
|
use vars qw($VERSION); |
|
95
|
|
|
|
|
213
|
|
|
95
|
|
|
|
|
8689
|
|
9
|
95
|
|
|
95
|
|
2069
|
$VERSION = '1.30'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
95
|
|
|
95
|
|
718
|
use Test::More; |
|
95
|
|
|
|
|
230
|
|
|
95
|
|
|
|
|
1122
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub checkStatusText { |
15
|
0
|
|
|
0
|
0
|
0
|
my ($content, $expected_lines) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
my @received_lines = split(/[\r?\n]/, $content); |
18
|
0
|
|
|
|
|
0
|
my @status = (); |
19
|
0
|
|
|
|
|
0
|
my ($regex, $line); |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
0
|
while ( defined ($line = shift(@received_lines))) { last if $line eq ""; } |
|
0
|
|
|
|
|
0
|
|
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
while (@received_lines) { |
24
|
0
|
|
|
|
|
0
|
my $expected_line = shift(@$expected_lines); |
25
|
0
|
|
|
|
|
0
|
my ($family, $job, $status, $rc, $tz, $start, $astart, $stop) = @$expected_line; |
26
|
0
|
|
|
|
|
0
|
my ($jb) = $job =~ /([^\-]+)/; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
$line = shift(@received_lines); $regex = "${family}::$job +$status +$rc +$tz +$start +$astart +$stop"; like($line, qr/$regex/, "Got Line $line"); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
29
|
|
|
|
|
|
|
} |
30
|
0
|
0
|
|
|
|
0
|
if (@$expected_lines) { |
31
|
0
|
|
|
|
|
0
|
diag("ERROR: expected a few more lines than we got"); |
32
|
0
|
|
|
|
|
0
|
die; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub checkStatus { |
40
|
0
|
|
|
0
|
0
|
0
|
my ($content, $expected_lines) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
my @received_lines = split(/[\r?\n]/, $content); |
43
|
0
|
|
|
|
|
0
|
my @status = (); |
44
|
0
|
|
|
|
|
0
|
my $html; |
45
|
0
|
0
|
|
|
|
0
|
while ( defined ($html = shift(@received_lines))) { last if $html eq " "; } |
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
while ($received_lines[0] ne "") { |
48
|
0
|
|
|
|
|
0
|
my $expected_line = shift(@$expected_lines); |
49
|
0
|
|
|
|
|
0
|
my ($family, $job, $status, $rc, $tz, $start, $astart, $stop) = @$expected_line; |
50
|
0
|
|
|
|
|
0
|
my ($jb) = $job =~ /([^\-]+)/; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ ], "Got '', "); |
|
0
|
|
|
|
|
0
|
|
53
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ Family Name], "Got ' Family Name', "); |
|
0
|
|
|
|
|
0
|
|
54
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ $family],"Got ' $family'"); |
|
0
|
|
|
|
|
0
|
|
55
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ Job Name], "Got ' Job Name', "); |
|
0
|
|
|
|
|
0
|
|
56
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ $job], "Got ' $job', "); |
|
0
|
|
|
|
|
0
|
|
57
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ Status], "Got ' Status', "); |
|
0
|
|
|
|
|
0
|
|
58
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ $status], "Got ' $status', "); |
|
0
|
|
|
|
|
0
|
|
59
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ Return Code], "Got ' Return Code', "); |
|
0
|
|
|
|
|
0
|
|
60
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ $rc], "Got ' $rc', "); |
|
0
|
|
|
|
|
0
|
|
61
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ Time Zone], "Got ' Time Zone', "); |
|
0
|
|
|
|
|
0
|
|
62
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ $tz], "Got ' $tz', "); |
|
0
|
|
|
|
|
0
|
|
63
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ Scheduled Start Time], "Got ' Scheduled Start Time', "); |
|
0
|
|
|
|
|
0
|
|
64
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ $start], "Got ' $start', "); |
|
0
|
|
|
|
|
0
|
|
65
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ Actual Start Time], "Got ' Actual Start Time', "); |
|
0
|
|
|
|
|
0
|
|
66
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ $astart], "Got ' $astart', "); |
|
0
|
|
|
|
|
0
|
|
67
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ Stop Time], "Got ' Stop Time', "); |
|
0
|
|
|
|
|
0
|
|
68
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ $stop], "Got ' $stop', "); |
|
0
|
|
|
|
|
0
|
|
69
|
0
|
|
|
|
|
0
|
$html = shift(@received_lines); is($html, qq[ ], "Got '', "); |
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub cleanup_files { |
74
|
229
|
|
|
229
|
0
|
39542344
|
my $dir = shift; |
75
|
229
|
|
|
|
|
1146
|
local *DIR; |
76
|
|
|
|
|
|
|
|
77
|
229
|
50
|
|
|
|
15418
|
opendir DIR, $dir or die "opendir $dir: $!"; |
78
|
229
|
|
|
|
|
631
|
my $found = 0; |
79
|
229
|
|
|
|
|
3790677
|
while ($_ = readdir DIR) { |
80
|
787
|
100
|
|
|
|
8083
|
next if /^\.{1,2}$/; |
81
|
329
|
|
|
|
|
2335
|
my $path = "$dir/$_"; |
82
|
329
|
50
|
|
|
|
2579775
|
unlink $path if -f $path; |
83
|
|
|
|
|
|
|
} |
84
|
229
|
|
|
|
|
79363
|
closedir DIR; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub fakeRun { |
89
|
0
|
|
|
0
|
0
|
0
|
my ($log_dir, $family, $job, $status) = @_; |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
0
|
open (OUT, ">$log_dir/$family.$job.pid") || die "Couldn't open pid file\n"; |
92
|
0
|
|
|
|
|
0
|
print OUT "pid: 111\nactual_start: 1209270000\nstop: 1209270001\nrc: $status\n"; |
93
|
0
|
|
|
|
|
0
|
close OUT; |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
0
|
open (OUT, ">$log_dir/$family.$job.started") || die "Couldn't open started file\n"; |
96
|
0
|
|
|
|
|
0
|
print OUT "00:00\n"; |
97
|
0
|
|
|
|
|
0
|
close OUT; |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
0
|
open (OUT, ">$log_dir/$family.$job.$status") || die "Couldn't open pid file\n"; |
100
|
0
|
|
|
|
|
0
|
print OUT "$status\n"; |
101
|
0
|
|
|
|
|
0
|
close OUT; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub waitForFiles { |
108
|
29
|
|
|
29
|
0
|
3167
|
my %args = @_; |
109
|
|
|
|
|
|
|
|
110
|
29
|
|
50
|
|
|
788
|
my $sleep_time = $args{sleep_time} || 3; |
111
|
29
|
|
50
|
|
|
409
|
my $num_tries = $args{num_tries} || 10; |
112
|
29
|
|
|
|
|
271
|
my $file_list = $args{file_list}; |
113
|
|
|
|
|
|
|
|
114
|
29
|
50
|
|
|
|
2039
|
next unless @$file_list; |
115
|
29
|
|
|
|
|
659
|
my $num_files = scalar(@$file_list); |
116
|
|
|
|
|
|
|
|
117
|
29
|
|
|
|
|
231
|
for (my $n = 1; $n <= $num_tries; $n++) { |
118
|
62
|
|
|
|
|
186043316
|
sleep $sleep_time; |
119
|
62
|
|
|
|
|
459
|
my $found = 1; |
120
|
62
|
|
|
|
|
350
|
my @missing = (); |
121
|
62
|
|
|
|
|
532
|
foreach my $file (@$file_list) { |
122
|
216
|
100
|
|
|
|
13209
|
if (! -e $file) { |
123
|
101
|
|
|
|
|
211
|
$found = 0; |
124
|
101
|
|
|
|
|
468
|
push (@missing, $file); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
62
|
100
|
|
|
|
1214
|
return 1 if $found; |
128
|
34
|
100
|
|
|
|
487
|
diag("Loop # $n: missing the following files:\n ", join("\n ", @missing), "\n") unless $n %5; |
129
|
|
|
|
|
|
|
} |
130
|
1
|
|
|
|
|
360
|
return 0; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub parseSMTPFile { |
135
|
0
|
|
|
0
|
0
|
|
my $file = shift; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
my @emails = (); |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
open (F, $file); |
140
|
0
|
|
|
|
|
|
my $email; |
141
|
|
|
|
|
|
|
my $mode; |
142
|
0
|
|
|
|
|
|
while () { |
143
|
0
|
|
|
|
|
|
s/[\r\n]//; |
144
|
0
|
0
|
|
|
|
|
if (/^Accepted Connection/) { |
|
|
0
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
$mode = 'smtp'; |
146
|
0
|
|
|
|
|
|
$email = { |
147
|
|
|
|
|
|
|
mail_from => '', |
148
|
|
|
|
|
|
|
rcpt_to => '', |
149
|
|
|
|
|
|
|
ehlo => '', |
150
|
|
|
|
|
|
|
from => '', |
151
|
|
|
|
|
|
|
to => '', |
152
|
|
|
|
|
|
|
return_path => '', |
153
|
|
|
|
|
|
|
reply_to => '', |
154
|
|
|
|
|
|
|
subject => '', |
155
|
|
|
|
|
|
|
body => [], |
156
|
|
|
|
|
|
|
}; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
elsif (/^C: < (.*)/) { |
159
|
0
|
|
|
|
|
|
my $line = $1; |
160
|
0
|
0
|
0
|
|
|
|
if ($mode eq 'smtp' && $line eq 'DATA') { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
$mode = 'header'; |
162
|
0
|
|
|
|
|
|
next; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
elsif ($mode eq 'header' && $line !~ /\S/) { |
165
|
0
|
|
|
|
|
|
$mode = 'message'; |
166
|
0
|
|
|
|
|
|
next; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
elsif ($mode eq 'message' && $line eq '.') { |
169
|
0
|
|
|
|
|
|
push (@emails, $email); |
170
|
0
|
|
|
|
|
|
$mode = ''; |
171
|
0
|
|
|
|
|
|
next; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
elsif ($mode eq 'smtp' && $line =~ /^(EHLO) (.*)/) { |
174
|
0
|
|
|
|
|
|
$email->{ehlo} = $2; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
elsif ($mode eq 'smtp' && $line =~ /^(HELO) (.*)/) { |
177
|
0
|
|
|
|
|
|
$email->{ehlo} = $2; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
elsif ($mode eq 'smtp' && $line =~ /^(MAIL FROM:)(.*)/) { |
180
|
0
|
|
|
|
|
|
$email->{mail_from} = $2; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
elsif ($mode eq 'smtp' && $line =~ /^(RCPT TO:)(.*)/) { |
183
|
0
|
|
|
|
|
|
$email->{rcpt_to} = $2; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
elsif ($mode eq 'header' && $line =~ /^([^:]+): (.*)/) { |
186
|
0
|
|
|
|
|
|
my $h = lc($1); |
187
|
0
|
|
|
|
|
|
my $v = $2; |
188
|
0
|
|
|
|
|
|
$h =~ s/\-/\_/g; |
189
|
0
|
|
|
|
|
|
$email->{$h} = $v; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
elsif ($mode eq 'message') { |
192
|
0
|
|
|
|
|
|
push (@{$email->{body}}, $line); |
|
0
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
return \@emails; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
1; |
202
|
|
|
|
|
|
|
|