8 plan skip_all => 'set TEST_MEMLEAK to enable this test'
9 unless $ENV{TEST_MEMLEAK};
13 use lib "$FindBin::Bin/lib";
14 use Catalyst::Test 'TestApp';
16 eval "use Proc::ProcessTable";
17 plan skip_all => 'Proc::ProcessTable required for this test' if $@;
19 eval "use HTTP::Body 0.03";
20 plan skip_all => 'HTTP::Body >= 0.03 required for this test' if $@;
23 plan skip_all => 'YAML required for this test' if $@;
25 our $t = Proc::ProcessTable->new( cache_ttys => 1 );
26 our ( $initial, $final ) = ( 0, 0 );
27 our $tests = YAML::LoadFile("$FindBin::Bin/optional_stress.yml");
31 # let the user specify a single uri to test
32 my $user_test = shift;
35 run_test( $user_test );
37 # otherwise, run all tests
39 map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
40 plan tests => $total_tests;
42 foreach my $test_group ( keys %{$tests} ) {
43 foreach my $test ( @{ $tests->{$test_group} } ) {
50 my $uri = shift || die 'No URI given for test';
52 print "TESTING $uri\n";
54 # make a few requests to set initial memory size
59 $initial = size_of($$);
60 print "Initial Size: $initial\n";
67 print "Final Size: $final\n";
69 if ( $final > $initial ) {
70 print "Leaked: " . ($final - $initial) . "K\n";
73 is( $final, $initial, "'$uri' memory is not leaking" );
79 foreach my $p ( @{ $t->table } ) {
80 if ( $p->pid == $pid ) {
85 die "Pid $pid not found?";