2 Test::Valgrind - Test Perl code through valgrind.
8 # From the command-line
9 perl -MTest::Valgrind leaky.pl
13 eval 'use Test::Valgrind';
14 plan skip_all => 'Test::Valgrind is required to test your distribution with valgrind' if $@;
17 # In all the test files of a directory
18 prove --exec 'perl -Iblib/lib -Iblib/arch -MTest::Valgrind' t/*.t
21 This module is a front-end to the "Test::Valgrind::*" API that lets you
22 run Perl code through the "memcheck" tool of the "valgrind" memory
23 debugger, to test it for memory errors and leaks. If they aren't
24 available yet, it will first generate suppressions for the current
25 "perl" interpreter and store them in the portable flavour of
26 ~/.perl/Test-Valgrind/suppressions/$VERSION. The actual run will then
27 take place, and tests will be passed or failed according to the result
30 Due to the nature of perl's memory allocator, this module can't track
31 leaks of Perl objects. This includes non-mortalized scalars and memory
32 cycles. However, it can track leaks of chunks of memory allocated in XS
33 extensions with "Newx" and friends or "malloc". As such, it's
34 complementary to the other very good leak detectors listed in the "SEE
38 You can pass parameters to "import" as a list of key / value pairs,
39 where valid keys are :
43 The Test::Valgrind::Tool object (or class name) to use.
45 Defaults to Test::Valgrind::Tool::memcheck.
49 The Test::Valgrind::Action object (or class name) to use.
51 Defaults to Test::Valgrind::Action::Test.
55 If true, print the output of the test script as diagnostics.
57 * "callers => $number"
59 Specify the maximum stack depth studied when valgrind encounters an
60 error. Raising this number improves granularity.
64 * "extra_supps => \@files"
66 Also use suppressions from @files besides "perl"'s.
68 * "no_def_supp => $bool"
70 If true, do not use the default suppression file.
73 You can't use this module to test code given by the "-e" command-line
76 Perl 5.8 is notorious for leaking like there's no tomorrow, so the
77 suppressions are very likely not to be very accurate on it. Anyhow,
78 results will most likely be better if your perl is built with debugging
79 enabled. Using the latest "valgrind" available will also help.
81 This module is not really secure. It's definitely not taint safe. That
82 shouldn't be a problem for test files.
84 What your tests output to "STDOUT" and "STDERR" is eaten unless you pass
85 the "diag" option, in which case it will be reprinted as diagnostics.
88 Valgrind 3.1.0 (<http://valgrind.org>).
90 XML::Twig, version, File::HomeDir, Env::Sanctify, Perl::Destruct::Level.
93 All the "Test::Valgrind::*" API, including Test::Valgrind::Command,
94 Test::Valgrind::Tool, Test::Valgrind::Action and
95 Test::Valgrind::Session.
99 Devel::Leak, Devel::LeakTrace, Devel::LeakTrace::Fast.
102 Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
104 You can contact me by mail or on "irc.perl.org" (vincent).
107 Please report any bugs or feature requests to "bug-test-valgrind at
108 rt.cpan.org", or through the web interface at
109 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>. I will
110 be notified, and then you'll automatically be notified of progress on
111 your bug as I make changes.
114 You can find documentation for this module with the perldoc command.
116 perldoc Test::Valgrind
119 Rafaƫl Garcia-Suarez, for writing and instructing me about the
120 existence of Perl::Destruct::Level (Elizabeth Mattijsen is a close
123 H.Merijn Brand, for daring to test this thing.
125 All you people that showed interest in this module, which motivated me
126 into completely rewriting it.
129 Copyright 2008-2009 Vincent Pit, all rights reserved.
131 This program is free software; you can redistribute it and/or modify it
132 under the same terms as Perl itself.