Test::MultiProcess - Run identical code in multiple fork'ed processes
use Test::MultiProcess; my $results = run_forked( code => sub { }, forks => 10 );
This module provides a single function, run_forked, which takes a coderef and a number of times to fork for the given code. The obvious use here is testing code that does something that could encounter problems while running simultaneously in multiple processes or threads: stress testing, concurreny testing, locking testing, and so on.
Each forked processes runs the code provided. That code should return a string value. Returned values get written to a shared mmap cache, which are returned by the run_forked() function. The returned structure is a hashref with the string values as keys, and values representing the number of times the string was returned.
See the tests in t/ for examples.
Note that I don't necessary believe this is the ideal way to perform certain types of testing. This module is in no way thorough, but it does provide a simple way to run code in many processes simultaneously. And nothing more.
run_forked()
fork();
Danny Brian, <dbrian@conceptuary.com>
Copyright (C) 2010 by Danny Brian
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.
To install Test::MultiProcess, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::MultiProcess
CPAN shell
perl -MCPAN -e shell install Test::MultiProcess
For more information on module installation, please visit the detailed CPAN module installation guide.