The Perl Advent Calendar needs more articles for 2022. Submit your idea today!


Test::RunValgrind - tests that an external program is valgrind-clean.


version 0.2.2


    use Test::More tests => 1;
    use Test::RunValgrind;

    # TEST
    Test::RunValgrind->new( {} )->run(
            log_fn => './expr--valgrind-log.txt',
            prog   => '/usr/bin/expr',
            argv   => [qw/5 + 6/],
            blurb  => 'valgrind likes /usr/bin/expr',


valgrind is an open source and convenient memory debugger that runs on some platforms. This module runs valgrind ( on an executable and makes sure that valgrind did not find any faults in it.

It originated from some code used to test the Freecell Solver executables using valgrind, and was extracted into its own CPAN module to allow for reuse by other projects, including fortune-mod (


my $obj = Test::RunValgrind->new({})

The constructor - currently accepts a single hash reference and if its 'supress_stderr' key's value is true, supresses outputting STDERR if on successful subsequent tests (starting from version 0.0.2). Furthermore if 'ignore_leaks' is true, then reported memory leaks are ignored and their presence will still allow the tests to pass (starting from version 0.2.0, and see ).

'valgrind_args' may point to an array reference of extra command line arguments to valgrind. See ; since version 0.2.0.

$obj->run({ ... })

Runs valgrind.

Accepts a hash ref with the following keys:

  • blurb

    The Test::More test assertion blurb.

  • log_fn

    The path to write the log file to (and read from it). Make sure it is secured.

  • prog

    The path to the executable to run.

  • argv

    An array reference contains strings with command line arguments to the executable.

See the synopsis for an example.


Test::Valgrind - seems to be only for running perl itself under valgrind.

Devel::Valgrind::Client - wikipedia page. - original code using Test::RunValgrind in Freecell Solver



The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

Bugs / Feature Requests

Please report any bugs or feature requests by email to bug-test-runvalgrind at, or through the web interface at You will be automatically notified of any progress on the request by the system.

Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)

  git clone git://


Shlomi Fish <>


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


This software is Copyright (c) 2016 by Shlomi Fish.

This is free software, licensed under:

  The MIT (X11) License