line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Valgrind::Component; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
39
|
use strict; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
183
|
|
4
|
7
|
|
|
7
|
|
34
|
use warnings; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
271
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Test::Valgrind::Component - Base class for Test::Valgrind components. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 1.17 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.17'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class is the base for all others that act as components that can be started and stopped. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
7
|
|
|
7
|
|
34
|
use Scalar::Util (); |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
172
|
|
25
|
|
|
|
|
|
|
|
26
|
7
|
|
|
7
|
|
33
|
use base qw; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
3193
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 C |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $tvc = Test::Valgrind::Component->new; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Basic constructor. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
39
|
15
|
|
|
15
|
1
|
134
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
15
|
|
|
|
|
26
|
my $class = $self; |
42
|
15
|
50
|
|
|
|
89
|
if (Scalar::Util::blessed($self)) { |
43
|
0
|
|
|
|
|
0
|
$class = ref $self; |
44
|
0
|
0
|
|
|
|
0
|
if ($self->isa(__PACKAGE__)) { |
45
|
0
|
|
|
|
|
0
|
$self->{started} = undef; |
46
|
0
|
|
|
|
|
0
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
bless { |
51
|
15
|
|
|
|
|
215
|
started => undef, |
52
|
|
|
|
|
|
|
}, $class; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$tvc->started($bool); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Specifies whether the component is running (C<1>), stopped (C<0>) or was never started (C). |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
38
|
100
|
|
38
|
1
|
298
|
sub started { @_ <= 1 ? $_[0]->{started} : ($_[0]->{started} = $_[1] ? 1 : 0) } |
|
|
100
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 C |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$tvc->start; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Marks the component as started, and throws an exception if it was already. |
70
|
|
|
|
|
|
|
Returns its self object. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub start { |
75
|
12
|
|
|
12
|
1
|
34
|
my ($self) = @_; |
76
|
|
|
|
|
|
|
|
77
|
12
|
50
|
|
|
|
114
|
$self->_croak(ref($self) . ' component already started') if $self->started; |
78
|
12
|
|
|
|
|
42
|
$self->started(1); |
79
|
|
|
|
|
|
|
|
80
|
12
|
|
|
|
|
40
|
$self; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 C |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$tvc->finish; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Marks the component as stopped, and throws an exception if it wasn't started. |
88
|
|
|
|
|
|
|
Returns its self object. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub finish { |
93
|
6
|
|
|
6
|
1
|
15
|
my ($self) = @_; |
94
|
|
|
|
|
|
|
|
95
|
6
|
50
|
|
|
|
26
|
$self->_croak(ref($self) . ' component is not started') unless $self->started; |
96
|
6
|
|
|
|
|
22
|
$self->started(0); |
97
|
|
|
|
|
|
|
|
98
|
6
|
|
|
|
|
18
|
$self; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SEE ALSO |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Vincent Pit, C<< >>, L. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
You can contact me by mail or on C (vincent). |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 BUGS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. |
114
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SUPPORT |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
perldoc Test::Valgrind::Component |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Copyright 2009,2010,2011,2013,2015 Vincent Pit, all rights reserved. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; # End of Test::Valgrind::Component |