.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test::Valgrind 3pm" .TH Test::Valgrind 3pm "2023-08-04" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::Valgrind \- Generate suppressions, analyse and test any command with valgrind. .SH "VERSION" .IX Header "VERSION" Version 1.19 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # From the command\-line \& perl \-MTest::Valgrind leaky.pl \& \& # From the command\-line, snippet style \& perl \-MTest::Valgrind \-e \*(Aqleaky()\*(Aq \& \& # In a test file \& use Test::More; \& eval \*(Aquse Test::Valgrind\*(Aq; \& plan skip_all => \*(AqTest::Valgrind is required to test your distribution with valgrind\*(Aq if $@; \& leaky(); \& \& # In all the test files of a directory \& prove \-\-exec \*(Aqperl \-Iblib/lib \-Iblib/arch \-MTest::Valgrind\*(Aq t/*.t .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is a front-end to the \f(CW\*(C`Test::Valgrind::*\*(C'\fR \s-1API\s0 that lets you run Perl code through the \f(CW\*(C`memcheck\*(C'\fR tool of the \f(CW\*(C`valgrind\*(C'\fR memory debugger, to test for memory errors and leaks. If they aren't available yet, it will first generate suppressions for the current \f(CW\*(C`perl\*(C'\fR interpreter and store them in the portable flavour of \fI~/.perl/Test\-Valgrind/suppressions/$VERSION\fR. The actual run will then take place, and tests will be passed or failed according to the result of the analysis. .PP The complete \s-1API\s0 is much more versatile than this. By declaring an appropriate Test::Valgrind::Command class, you can run any executable (that is, not only Perl scripts) under valgrind, generate the corresponding suppressions on-the-fly and convert the analysis result to \s-1TAP\s0 output so that it can be incorporated into your project's testsuite. If you're not interested in producing \s-1TAP,\s0 you can output the results in whatever format you like (for example \s-1HTML\s0 pages) by defining your own Test::Valgrind::Action class. .PP Due to the nature of perl's memory allocator, this module can't track leaks of Perl objects. This includes non-mortalized scalars and memory cycles. However, it can track leaks of chunks of memory allocated in \s-1XS\s0 extensions with \f(CW\*(C`Newx\*(C'\fR and friends or \f(CW\*(C`malloc\*(C'\fR. As such, it's complementary to the other very good leak detectors listed in the \*(L"\s-1SEE ALSO\*(R"\s0 section. .SH "METHODS" .IX Header "METHODS" .ie n .SS """analyse""" .el .SS "\f(CWanalyse\fP" .IX Subsection "analyse" .Vb 1 \& Test::Valgrind\->analyse(%options); .Ve .PP Run a \f(CW\*(C`valgrind\*(C'\fR analysis configured by \f(CW%options\fR : .IP "\(bu" 4 \&\f(CW\*(C`command => $command\*(C'\fR .Sp The Test::Valgrind::Command object (or class name) to use. .Sp Defaults to Test::Valgrind::Command::PerlScript. .IP "\(bu" 4 \&\f(CW\*(C`tool => $tool\*(C'\fR .Sp The Test::Valgrind::Tool object (or class name) to use. .Sp Defaults to Test::Valgrind::Tool::memcheck. .IP "\(bu" 4 \&\f(CW\*(C`action => $action\*(C'\fR .Sp The Test::Valgrind::Action object (or class name) to use. .Sp Defaults to Test::Valgrind::Action::Test. .IP "\(bu" 4 \&\f(CW\*(C`file => $file\*(C'\fR .Sp The file name of the script to analyse. .Sp Ignored if you supply your own custom \f(CW\*(C`command\*(C'\fR, but mandatory otherwise. .IP "\(bu" 4 \&\f(CW\*(C`callers => $number\*(C'\fR .Sp Specify the maximum stack depth studied when valgrind encounters an error. Raising this number improves granularity. .Sp Ignored if you supply your own custom \f(CW\*(C`tool\*(C'\fR, otherwise defaults to \f(CW24\fR (the maximum allowed by \f(CW\*(C`valgrind\*(C'\fR). .IP "\(bu" 4 \&\f(CW\*(C`diag => $bool\*(C'\fR .Sp If true, print the output of the test script as diagnostics. .Sp Ignored if you supply your own custom \f(CW\*(C`action\*(C'\fR, otherwise defaults to false. .IP "\(bu" 4 \&\f(CW\*(C`regen_def_supp => $bool\*(C'\fR .Sp If true, forcefully regenerate the default suppression file. .Sp Defaults to false. .IP "\(bu" 4 \&\f(CW\*(C`no_def_supp => $bool\*(C'\fR .Sp If true, do not use the default suppression file. .Sp Defaults to false. .IP "\(bu" 4 \&\f(CW\*(C`allow_no_supp => $bool\*(C'\fR .Sp If true, force running the analysis even if the suppression files do not refer to any \f(CW\*(C`perl\*(C'\fR\-related symbol. .Sp Defaults to false. .IP "\(bu" 4 \&\f(CW\*(C`extra_supps => \e@files\*(C'\fR .Sp Also use suppressions from \f(CW@files\fR besides \f(CW\*(C`perl\*(C'\fR's. .Sp Defaults to empty. .ie n .SS """import""" .el .SS "\f(CWimport\fP" .IX Subsection "import" .Vb 1 \& use Test::Valgrind %options; .Ve .PP In the parent process, \*(L"import\*(R" calls \*(L"analyse\*(R" with the arguments it received itself \- except that if no \f(CW\*(C`file\*(C'\fR option was supplied, it tries to pick the first caller context that looks like a script. When the analysis ends, it exits with the status returned by the action (for the default TAP-generator action, it's the number of failed tests). .PP In the child process, it just \f(CW\*(C`return\*(C'\fRs so that the calling code is actually run under \f(CW\*(C`valgrind\*(C'\fR, albeit two side-effects : .IP "\(bu" 4 Perl::Destruct::Level is loaded and the destruction level is set to \f(CW3\fR. .IP "\(bu" 4 Autoflush on \f(CW\*(C`STDOUT\*(C'\fR is turned on. .SH "VARIABLES" .IX Header "VARIABLES" .ie n .SS "$dl_unload" .el .SS "\f(CW$dl_unload\fP" .IX Subsection "$dl_unload" When set to true, all dynamic extensions that were loaded during the analysis will be unloaded at \f(CW\*(C`END\*(C'\fR time by \*(L"dl_unload_file\*(R" in DynaLoader. .PP Since this obfuscates error stack traces, it's disabled by default. .SH "CAVEATS" .IX Header "CAVEATS" Perl 5.8 is notorious for leaking like there's no tomorrow, so the suppressions are very likely not to be complete on it. You also have a better chance to get more accurate results if your perl is built with debugging enabled. Using the latest \f(CW\*(C`valgrind\*(C'\fR available will also help. .PP This module is not really secure. It's definitely not taint safe. That shouldn't be a problem for test files. .PP What your tests output to \f(CW\*(C`STDOUT\*(C'\fR and \f(CW\*(C`STDERR\*(C'\fR is eaten unless you pass the \f(CW\*(C`diag\*(C'\fR option, in which case it will be reprinted as diagnostics. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" XML::Twig, File::HomeDir, Env::Sanctify, Perl::Destruct::Level. .SH "SEE ALSO" .IX Header "SEE ALSO" All the \f(CW\*(C`Test::Valgrind::*\*(C'\fR \s-1API,\s0 including Test::Valgrind::Command, Test::Valgrind::Tool, Test::Valgrind::Action and Test::Valgrind::Session. .PP The \f(CWvalgrind(1)\fR man page. .PP Test::LeakTrace. .PP Devel::Leak, Devel::LeakTrace, Devel::LeakTrace::Fast. .SH "AUTHOR" .IX Header "AUTHOR" Vincent Pit, \f(CW\*(C`\*(C'\fR, . .PP You can contact me by mail or on \f(CW\*(C`irc.perl.org\*(C'\fR (vincent). .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-test\-valgrind at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Test::Valgrind .Ve .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" Rafaƫl Garcia-Suarez, for writing and instructing me about the existence of Perl::Destruct::Level (Elizabeth Mattijsen is a close second). .PP H.Merijn Brand, for daring to test this thing. .PP David Cantrell, for providing shell access to one of his smokers where the tests were failing. .PP The Debian-perl team, for offering all the feedback they could regarding the build issues they met. .PP All you people that showed interest in this module, which motivated me into completely rewriting it. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2008,2009,2010,2011,2013,2015,2016 Vincent Pit, all rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.