7 use lib "$FindBin::Bin/lib";
10 use Catalyst::Test 'TestApp';
12 plan skip_all => 'set TEST_MEMLEAK to enable this test'
13 unless $ENV{TEST_MEMLEAK};
15 eval "use Proc::ProcessTable";
16 plan skip_all => 'Proc::ProcessTable required for this test' if $@;
18 eval "use HTTP::Body 0.03";
19 plan skip_all => 'HTTP::Body >= 0.03 required for this test' if $@;
22 plan skip_all => 'YAML required for this test' if $@;
24 our $t = Proc::ProcessTable->new( cache_ttys => 1 );
25 our ( $initial, $final ) = ( 0, 0 );
26 our $tests = YAML::LoadFile("$FindBin::Bin/optional_stress.yml");
30 # let the user specify a single uri to test
31 my $user_test = shift;
34 run_test( $user_test );
36 # otherwise, run all tests
38 map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
39 plan tests => $total_tests;
41 foreach my $test_group ( keys %{$tests} ) {
42 foreach my $test ( @{ $tests->{$test_group} } ) {
49 my $uri = shift || die 'No URI given for test';
51 print "TESTING $uri\n";
53 # make a few requests to set initial memory size
58 $initial = size_of($$);
59 print "Initial Size: $initial\n";
66 print "Final Size: $final\n";
68 if ( $final > $initial ) {
69 print "Leaked: " . ($final - $initial) . "\n";
72 is( $final, $initial, "'$uri' memory is not leaking" );
78 foreach my $p ( @{ $t->table } ) {
79 if ( $p->pid == $pid ) {
84 die "Pid $pid not found?";