6 plan skip_all => 'set TEST_MEMLEAK to enable this test'
7 unless $ENV{TEST_MEMLEAK};
11 use lib "$FindBin::Bin/lib";
12 use Catalyst::Test 'TestApp';
14 eval "use Proc::ProcessTable";
15 plan skip_all => 'Proc::ProcessTable required for this test' if $@;
17 eval "use HTTP::Body 0.03";
18 plan skip_all => 'HTTP::Body >= 0.03 required for this test' if $@;
21 plan skip_all => 'YAML required for this test' if $@;
23 our $t = Proc::ProcessTable->new( cache_ttys => 1 );
24 our ( $initial, $final ) = ( 0, 0 );
25 our $tests = YAML::LoadFile("$FindBin::Bin/optional_stress.yml");
29 # let the user specify a single uri to test
30 my $user_test = shift;
33 run_test( $user_test );
35 # otherwise, run all tests
37 map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
38 plan tests => $total_tests;
40 foreach my $test_group ( keys %{$tests} ) {
41 foreach my $test ( @{ $tests->{$test_group} } ) {
48 my $uri = shift || die 'No URI given for test';
50 print "TESTING $uri\n";
52 # make a few requests to set initial memory size
57 $initial = size_of($$);
58 print "Initial Size: $initial\n";
65 print "Final Size: $final\n";
67 if ( $final > $initial ) {
68 print "Leaked: " . ($final - $initial) . "K\n";
71 is( $final, $initial, "'$uri' memory is not leaking" );
77 foreach my $p ( @{ $t->table } ) {
78 if ( $p->pid == $pid ) {
83 die "Pid $pid not found?";