line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Csistck::Test; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
308
|
use 5.010; |
|
17
|
|
|
|
|
51
|
|
|
17
|
|
|
|
|
1343
|
|
4
|
17
|
|
|
17
|
|
86
|
use strict; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
442
|
|
5
|
17
|
|
|
17
|
|
78
|
use warnings; |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
480
|
|
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
83
|
use base 'Exporter'; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
1413
|
|
8
|
17
|
|
|
17
|
|
28175
|
use Csistck::Oper; |
|
17
|
|
|
|
|
454
|
|
|
17
|
|
|
|
|
913
|
|
9
|
17
|
|
|
17
|
|
13447
|
use Csistck::Test::Return; |
|
17
|
|
|
|
|
43
|
|
|
17
|
|
|
|
|
611
|
|
10
|
|
|
|
|
|
|
|
11
|
17
|
|
|
17
|
|
109
|
use Scalar::Util qw/blessed/; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
24854
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
35
|
|
|
35
|
0
|
2456
|
my $class = shift; |
15
|
35
|
|
|
|
|
145
|
my $target = shift; |
16
|
|
|
|
|
|
|
|
17
|
35
|
|
|
|
|
414
|
bless { |
18
|
|
|
|
|
|
|
desc => "Unidentified test", |
19
|
|
|
|
|
|
|
target => $target, |
20
|
|
|
|
|
|
|
on_repair => undef, |
21
|
|
|
|
|
|
|
@_ |
22
|
|
|
|
|
|
|
}, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
10
|
|
|
10
|
0
|
53
|
sub desc { shift->{desc}; } |
26
|
16
|
|
|
16
|
0
|
82
|
sub target { shift->{target}; } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub on_repair { |
29
|
4
|
|
|
4
|
0
|
72
|
my $func = shift->{on_repair}; |
30
|
4
|
50
|
|
|
|
32
|
return $func if (ref $func eq 'CODE'); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# This is used to wrap processes |
34
|
|
|
|
|
|
|
sub execute { |
35
|
25
|
|
|
25
|
0
|
180
|
my ($self, $mode) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# We will exit with pass here, as to not throw an error. It is not the fault |
38
|
|
|
|
|
|
|
# of the user if the test has no check or repair operation |
39
|
25
|
|
|
0
|
|
145
|
my $func = sub {}; |
|
0
|
|
|
|
|
0
|
|
40
|
25
|
100
|
|
|
|
197
|
unless ($self->can($mode)) { |
41
|
2
|
|
|
|
|
18
|
return $self->fail('Test missing mode'); |
42
|
|
|
|
|
|
|
# TODO make this better error |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
23
|
|
|
|
|
62
|
given ($mode) { |
46
|
23
|
50
|
|
17
|
|
117
|
when ("check") { $func = sub { $self->check } if ($self->can('check')); } |
|
17
|
|
|
|
|
305
|
|
|
17
|
|
|
|
|
189
|
|
47
|
6
|
50
|
|
6
|
|
18
|
when ("repair") { $func = sub { $self->repair } if ($self->can('repair')); } |
|
6
|
|
|
|
|
116
|
|
|
6
|
|
|
|
|
35
|
|
48
|
0
|
0
|
|
0
|
|
0
|
when ("diff") { $func = sub { $self->diff } if ($self->can('diff')); } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
23
|
|
|
|
|
330
|
Csistck::Oper::info($self->desc); |
52
|
23
|
|
|
|
|
47
|
my $ret = eval { &{$func}; }; |
|
23
|
|
|
|
|
197
|
|
|
23
|
|
|
|
|
64
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Catch errors |
55
|
23
|
50
|
|
|
|
142
|
if ($@) { |
56
|
0
|
|
|
|
|
0
|
my $error = $@; |
57
|
0
|
|
|
|
|
0
|
$error =~ s/ at [A-Za-z0-9\/\_\-\.]+ line [0-9]+.\n//; |
58
|
0
|
|
|
|
|
0
|
Csistck::Oper::error(sprintf("%s: %s", $self->desc, $error)); |
59
|
0
|
|
|
|
|
0
|
return $self->fail($error); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Return should be an object from now on. If not blessed, assume ret value |
63
|
23
|
50
|
33
|
|
|
802
|
if (blessed($ret) and $ret->isa('Csistck::Test::Return')) { |
64
|
23
|
100
|
|
|
|
118
|
if ($ret->resp) { |
65
|
15
|
|
|
|
|
70
|
Csistck::Oper::info($ret->msg); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
8
|
|
|
|
|
62
|
Csistck::Oper::error($ret->msg); |
69
|
|
|
|
|
|
|
} |
70
|
23
|
|
|
|
|
7689
|
return $ret; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
0
|
|
|
|
|
0
|
return $self->ret($ret, "Test response"); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Return test response |
78
|
|
|
|
|
|
|
sub ret { |
79
|
29
|
|
|
29
|
0
|
170
|
my ($self, $resp, $msg) = @_; |
80
|
29
|
|
|
|
|
357
|
return Csistck::Test::Return->new( |
81
|
|
|
|
|
|
|
desc => $self->desc, |
82
|
|
|
|
|
|
|
resp => $resp, |
83
|
|
|
|
|
|
|
msg => $msg |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
} |
86
|
13
|
|
|
13
|
0
|
127
|
sub fail { shift->ret(0, @_); } |
87
|
16
|
|
|
16
|
0
|
141
|
sub pass { shift->ret(1, @_); } |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |