]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blob - README
Also strip the (new) tail after cutting the suppression at Perl_runops
[perl/modules/Test-Valgrind.git] / README
1 NAME
2     Test::Valgrind - Generate suppressions, analyse and test any command
3     with valgrind.
4
5 VERSION
6     Version 1.11
7
8 SYNOPSIS
9         # From the command-line
10         perl -MTest::Valgrind leaky.pl
11
12         # From the command-line, snippet style
13         perl -MTest::Valgrind -e 'leaky()'
14
15         # In a test file
16         use Test::More;
17         eval 'use Test::Valgrind';
18         plan skip_all => 'Test::Valgrind is required to test your distribution with valgrind' if $@;
19         leaky();
20
21         # In all the test files of a directory
22         prove --exec 'perl -Iblib/lib -Iblib/arch -MTest::Valgrind' t/*.t
23
24 DESCRIPTION
25     This module is a front-end to the "Test::Valgrind::*" API that lets you
26     run Perl code through the "memcheck" tool of the "valgrind" memory
27     debugger, to test it for memory errors and leaks. If they aren't
28     available yet, it will first generate suppressions for the current
29     "perl" interpreter and store them in the portable flavour of
30     ~/.perl/Test-Valgrind/suppressions/$VERSION. The actual run will then
31     take place, and tests will be passed or failed according to the result
32     of the analysis.
33
34     The complete API is much more versatile than this. It allows you to run
35     *any* executable under valgrind, generate the corresponding suppressions
36     and convert the analysis output to TAP so that it can be incorporated
37     into your project's testsuite.
38
39     Due to the nature of perl's memory allocator, this module can't track
40     leaks of Perl objects. This includes non-mortalized scalars and memory
41     cycles. However, it can track leaks of chunks of memory allocated in XS
42     extensions with "Newx" and friends or "malloc". As such, it's
43     complementary to the other very good leak detectors listed in the "SEE
44     ALSO" section.
45
46 METHODS
47   "analyse [ %options ]"
48     Run a "valgrind" analysis configured by %options :
49
50     *   "command => $command"
51
52         The Test::Valgrind::Command object (or class name) to use.
53
54         Defaults to Test::Valgrind::Command::PerlScript.
55
56     *   "tool => $tool"
57
58         The Test::Valgrind::Tool object (or class name) to use.
59
60         Defaults to Test::Valgrind::Tool::memcheck.
61
62     *   "action => $action"
63
64         The Test::Valgrind::Action object (or class name) to use.
65
66         Defaults to Test::Valgrind::Action::Test.
67
68     *   "file => $file"
69
70         The file name of the script to analyse.
71
72         Ignored if you supply your own custom "command", but mandatory
73         otherwise.
74
75     *   "callers => $number"
76
77         Specify the maximum stack depth studied when valgrind encounters an
78         error. Raising this number improves granularity.
79
80         Ignored if you supply your own custom "tool", otherwise defaults to
81         12.
82
83     *   "diag => $bool"
84
85         If true, print the output of the test script as diagnostics.
86
87         Ignored if you supply your own custom "action", otherwise defaults
88         to false.
89
90     *   "extra_supps => \@files"
91
92         Also use suppressions from @files besides "perl"'s.
93
94         Defaults to empty.
95
96     *   "no_def_supp => $bool"
97
98         If true, do not use the default suppression file.
99
100         Defaults to false.
101
102   "import [ %options ]"
103     In the parent process, "import" calls "analyse" with the arguments it
104     received itself - except that if no "file" option was supplied, it tries
105     to pick the first caller context that looks like a script. When the
106     analyse ends, it exits with the status that was returned.
107
108     In the child process, it just "return"s so that the calling code is
109     actually run under "valgrind".
110
111 VARIABLES
112   $dl_unload
113     When set to true, all dynamic extensions that were loaded during the
114     analysis will be unloaded at "END" time by "dl_unload_file" in
115     DynaLoader.
116
117     Since this obfuscates error stack traces, it's disabled by default.
118
119 CAVEATS
120     Perl 5.8 is notorious for leaking like there's no tomorrow, so the
121     suppressions are very likely not to be very accurate on it. Anyhow,
122     results will most likely be better if your perl is built with debugging
123     enabled. Using the latest "valgrind" available will also help.
124
125     This module is not really secure. It's definitely not taint safe. That
126     shouldn't be a problem for test files.
127
128     What your tests output to "STDOUT" and "STDERR" is eaten unless you pass
129     the "diag" option, in which case it will be reprinted as diagnostics.
130
131 DEPENDENCIES
132     XML::Twig, version, File::HomeDir, Env::Sanctify, Perl::Destruct::Level.
133
134 SEE ALSO
135     All the "Test::Valgrind::*" API, including Test::Valgrind::Command,
136     Test::Valgrind::Tool, Test::Valgrind::Action and
137     Test::Valgrind::Session.
138
139     The valgrind(1) man page.
140
141     Test::LeakTrace.
142
143     Devel::Leak, Devel::LeakTrace, Devel::LeakTrace::Fast.
144
145 AUTHOR
146     Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
147
148     You can contact me by mail or on "irc.perl.org" (vincent).
149
150 BUGS
151     Please report any bugs or feature requests to "bug-test-valgrind at
152     rt.cpan.org", or through the web interface at
153     <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>. I will
154     be notified, and then you'll automatically be notified of progress on
155     your bug as I make changes.
156
157 SUPPORT
158     You can find documentation for this module with the perldoc command.
159
160         perldoc Test::Valgrind
161
162 ACKNOWLEDGEMENTS
163     RafaĆ«l Garcia-Suarez, for writing and instructing me about the
164     existence of Perl::Destruct::Level (Elizabeth Mattijsen is a close
165     second).
166
167     H.Merijn Brand, for daring to test this thing.
168
169     All you people that showed interest in this module, which motivated me
170     into completely rewriting it.
171
172 COPYRIGHT & LICENSE
173     Copyright 2008-2009 Vincent Pit, all rights reserved.
174
175     This program is free software; you can redistribute it and/or modify it
176     under the same terms as Perl itself.
177