7 use lib "$FindBin::Bin/lib";
10 use Catalyst::Test 'TestApp';
12 eval "use Proc::ProcessTable";
14 plan skip_all => 'set TEST_MEMLEAK to enable this test'
15 unless $ENV{TEST_MEMLEAK};
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 $@;
21 our $t = Proc::ProcessTable->new( cache_ttys => 1 );
22 our ( $initial, $final ) = ( 0, 0 );
23 our $tests = YAML::LoadFile("$FindBin::Bin/optional_stress.yml");
27 # let the user specify a single uri to test
28 my $user_test = shift;
31 run_test( $user_test );
33 # otherwise, run all tests
35 map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
36 plan tests => $total_tests;
38 foreach my $test_group ( keys %{$tests} ) {
39 foreach my $test ( @{ $tests->{$test_group} } ) {
46 my $uri = shift || die 'No URI given for test';
48 print "TESTING $uri\n";
50 # make a few requests to set initial memory size
55 $initial = size_of($$);
56 print "Initial Size: $initial\n";
63 print "Final Size: $final\n";
65 if ( $final > $initial ) {
66 print "Leaked: " . ($final - $initial) . "\n";
69 is( $final, $initial, "'$uri' memory is not leaking" );
75 foreach my $p ( @{ $t->table } ) {
76 if ( $p->pid == $pid ) {
81 die "Pid $pid not found?";