line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Csistck::Test::Script; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
332
|
use 5.010; |
|
17
|
|
|
|
|
49
|
|
4
|
17
|
|
|
17
|
|
83
|
use strict; |
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
400
|
|
5
|
17
|
|
|
17
|
|
78
|
use warnings; |
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
513
|
|
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
74
|
use base 'Csistck::Test'; |
|
17
|
|
|
|
|
24
|
|
|
17
|
|
|
|
|
1485
|
|
8
|
17
|
|
|
17
|
|
83
|
use Csistck::Oper qw/debug/; |
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
847
|
|
9
|
17
|
|
|
17
|
|
91
|
use Csistck::Config qw/option/; |
|
17
|
|
|
|
|
25
|
|
|
17
|
|
|
|
|
1078
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw/script/; |
12
|
|
|
|
|
|
|
|
13
|
17
|
|
|
17
|
|
84
|
use Digest::MD5; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
602
|
|
14
|
17
|
|
|
17
|
|
80
|
use File::Basename; |
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
1048
|
|
15
|
17
|
|
|
17
|
|
84
|
use FindBin; |
|
17
|
|
|
|
|
25
|
|
|
17
|
|
|
|
|
648
|
|
16
|
|
|
|
|
|
|
|
17
|
17
|
|
|
17
|
|
82
|
use constant MODE_CHECK => 'check'; |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
1242
|
|
18
|
17
|
|
|
17
|
|
88
|
use constant MODE_REPAIR => 'run'; |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
5713
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Use the convenience function to normalize args |
21
|
|
|
|
|
|
|
sub script { |
22
|
3
|
|
|
3
|
1
|
1116
|
my $script = shift; |
23
|
3
|
|
100
|
|
|
26
|
my $script_args = shift // []; |
24
|
3
|
50
|
|
|
|
31
|
my %args = ( |
25
|
|
|
|
|
|
|
args => (ref $script_args eq 'ARRAY') ? |
26
|
|
|
|
|
|
|
$script_args : |
27
|
|
|
|
|
|
|
[$script_args], |
28
|
|
|
|
|
|
|
@_ |
29
|
|
|
|
|
|
|
); |
30
|
3
|
|
|
|
|
62
|
Csistck::Test::Script->new($script, %args); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
20
|
|
|
20
|
0
|
220
|
sub script_name { shift->{target}; } |
34
|
8
|
|
|
8
|
0
|
34
|
sub args { shift->{args}; } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Wrap common process function |
37
|
12
|
|
|
12
|
0
|
449
|
sub desc { return sprintf("Script test for %s", shift->script_name); } |
38
|
6
|
|
|
6
|
0
|
937
|
sub check { shift->process(MODE_CHECK); } |
39
|
2
|
|
|
2
|
0
|
11
|
sub repair { shift->process(MODE_REPAIR); } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub process { |
42
|
8
|
|
|
8
|
0
|
16
|
my $self = shift; |
43
|
8
|
|
|
|
|
23
|
my $mode = shift; |
44
|
8
|
|
|
|
|
18
|
my $script = $self->script_name; |
45
|
|
|
|
|
|
|
# Args was passed as arrayref |
46
|
8
|
|
|
|
|
12
|
my @args = @{$self->args}; |
|
8
|
|
|
|
|
21
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# TODO sanity check on script |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Build command |
51
|
8
|
|
|
|
|
20
|
my @command = ($script, $mode, @args); |
52
|
8
|
|
|
|
|
83
|
debug(sprintf("Run command: cmd=<%s>", join(" ", @command))); |
53
|
8
|
|
|
|
|
185
|
chdir($FindBin::Bin); |
54
|
8
|
|
|
|
|
36921
|
my $ret = system(@command); |
55
|
|
|
|
|
|
|
|
56
|
8
|
100
|
|
|
|
434
|
return (($ret == 0) ? $self->pass('Command passed') : |
57
|
|
|
|
|
|
|
$self->fail('Command failed')); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
__END__ |