1 package Test::Valgrind::Tool;
8 Test::Valgrind::Tool - Base class for Test::Valgrind tools.
16 our $VERSION = '1.17';
20 This class is the base for L<Test::Valgrind> tools.
22 They wrap around C<valgrind> tools by parsing its output and sending reports to the parent session whenever an error occurs.
23 They are expected to function both in suppressions generation and in analysis mode.
27 use Test::Valgrind::Util;
29 use base qw<Test::Valgrind::Component Test::Valgrind::Carp>;
33 =head2 C<requires_version>
35 my $required_version = $tvt->requires_version;
37 The minimum C<valgrind> version needed to run this tool.
42 sub requires_version { '3.1.0' }
46 my $tvt = Test::Valgrind::Tool->new(tool => $tool);
48 Creates a new tool object of type C<$tool> by requiring and redispatching the method call to the module named C<$tool> if it contains C<'::'> or to C<Test::Valgrind::Tool::$tool> otherwise.
49 The class represented by C<$tool> must inherit this class.
55 $class = ref($class) || $class;
59 if ($class eq __PACKAGE__) {
60 my ($tool, $msg) = Test::Valgrind::Util::validate_subclass(
61 delete $args{tool} || 'memcheck',
63 $class->_croak($msg) unless defined $tool;
64 return $tool->new(%args);
67 $class->SUPER::new(@_);
72 my $tvt_train = Test::Valgrind::Tool->new_trainer;
74 Creates a new tool object suitable for generating suppressions.
76 Defaults to return C<undef>, which skips suppression generation.
82 =head2 C<parser_class>
84 my $parser_class = $tvt->parser_class($session);
86 Returns the class from which the parser for this tool output will be instanciated.
88 This method must be implemented when subclassing.
94 =head2 C<report_class>
96 my $report_class = $tvt->report_class($session);
98 Returns the class in which suppression reports generated by this tool will be blessed.
100 This method must be implemented when subclassing.
108 my @args = $tvt->args($session);
110 Returns the list of tool-specific arguments that are to be passed to C<valgrind>.
111 All the suppression arguments are already handled by the session.
113 Defaults to the empty list.
119 =head2 C<suppressions_tag>
121 my $tag = $tvt->suppressions_tag($session);
123 Returns a identifier that will be used to pick up the right suppressions for running the tool, or C<undef> to indicate that no special suppressions are needed.
125 This method must be implemented when subclassing.
129 sub suppressions_tag;
133 $tvt->start($session);
135 Called when the C<$session> starts.
137 Defaults to set L<Test::Valgrind::Component/started>.
141 my $filtered_report = $tvt->filter($session, $report);
143 The C<$session> calls this method after receiving a report from the parser and before letting the command filter it.
144 You can either return a mangled C<$report> (which does not need to be a clone of the original) or C<undef> if you want the action to ignore it completely.
146 Defaults to the identity function.
154 $tvt->finish($session);
156 Called when the C<$session> finishes.
158 Defaults to clear L<Test::Valgrind::Component/started>.
162 L<Test::Valgrind>, L<Test::Valgrind::Component>, L<Test::Valgrind::Session>.
166 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
168 You can contact me by mail or on C<irc.perl.org> (vincent).
172 Please report any bugs or feature requests to C<bug-test-valgrind at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>.
173 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
177 You can find documentation for this module with the perldoc command.
179 perldoc Test::Valgrind::Tool
181 =head1 COPYRIGHT & LICENSE
183 Copyright 2009,2010,2011,2013,2015 Vincent Pit, all rights reserved.
185 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
189 1; # End of Test::Valgrind::Tool