NAME

Test::MultiProcess - Run identical code in multiple fork'ed processes

SYNOPSIS

use Test::MultiProcess;
my $results = run_forked(
  code => sub { },
  forks => 10
);

DESCRIPTION

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.

EXPORT

run_forked()

SEE ALSO

fork();

AUTHOR

Danny Brian, <dbrian@conceptuary.com>

COPYRIGHT AND LICENSE

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.