1 package Test::Valgrind::Suppressions;
8 Test::Valgrind::Suppressions - Generate suppressions for given tool and command.
16 our $VERSION = '1.11';
20 This module is an helper for generating suppressions.
24 use base qw/Test::Valgrind::Carp/;
28 =head2 C<< generate tool => $tool, command => $command, target => $target >>
30 Generates suppressions for the command C<< $command->new_trainer >> and the tool C<< $tool->new_trainer >>, and writes them in the file specified by C<$target>.
31 The action used behind the scenes is L<Test::Valgrind::Action::Suppressions>.
33 Returns the status code.
42 my $cmd = delete $args{command};
44 require Test::Valgrind::Command;
45 $cmd = Test::Valgrind::Command->new(
50 $cmd = $cmd->new_trainer;
51 return unless defined $cmd;
53 my $tool = delete $args{tool};
55 require Test::Valgrind::Tool;
56 $tool = Test::Valgrind::Tool->new(tool => $tool);
58 $tool = $tool->new_trainer;
59 return unless defined $tool;
61 my $target = delete $args{target};
62 $self->_croak('Invalid target') unless $target and not ref $target;
64 require Test::Valgrind::Action;
65 my $action = Test::Valgrind::Action->new(
66 action => 'Suppressions',
68 name => 'PerlSuppression',
71 require Test::Valgrind::Session;
72 my $sess = Test::Valgrind::Session->new(
73 min_version => $tool->requires_version,
83 $self->_croak($@) if $@;
85 my $status = $sess->status;
86 $status = 255 unless defined $status;
91 =head2 C<strip_tail $session, $suppression>
93 Removes all wildcard frames at the end of the suppression.
94 Moreover, C<'...'> is appended when C<valgrind> C<3.4.0> or higher is used.
95 Returns the mangled suppression.
102 my ($sess, $supp) = @_;
104 1 while $supp =~ s/[^\r\n]*:\s*\*\s*$//;
105 # With valgrind 3.4.0, we can replace unknown series of frames by '...'
106 if ($sess->version ge '3.4.0') {
107 1 while $supp =~ s/[^\r\n]*\.{3}\s*$//;
116 L<Test::Valgrind>, L<Test::Valgrind::Command>, L<Test::Valgrind::Tool>, L<Test::Valgrind::Action::Suppressions>.
120 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
122 You can contact me by mail or on C<irc.perl.org> (vincent).
126 Please report any bugs or feature requests to C<bug-test-valgrind-suppressions at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>.
127 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
131 You can find documentation for this module with the perldoc command.
133 perldoc Test::Valgrind::Suppressions
135 =head1 COPYRIGHT & LICENSE
137 Copyright 2008-2009 Vincent Pit, all rights reserved.
139 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
143 1; # End of Test::Valgrind::Suppressions