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 $@;
20 use JSON::MaybeXS qw(decode_json);
22 our $t = Proc::ProcessTable->new( cache_ttys => 1 );
23 our ( $initial, $final ) = ( 0, 0 );
25 open my $fh, '<:raw', "$FindBin::Bin/optional_stress.json" or die "$!";
30 our $tests = decode_json($test_data);
34 # let the user specify a single uri to test
35 my $user_test = shift;
38 run_test( $user_test );
40 # otherwise, run all tests
42 map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
43 plan tests => $total_tests;
45 foreach my $test_group ( keys %{$tests} ) {
46 foreach my $test ( @{ $tests->{$test_group} } ) {
53 my $uri = shift || die 'No URI given for test';
55 print "TESTING $uri\n";
57 # make a few requests to set initial memory size
62 $initial = size_of($$);
63 print "Initial Size: $initial\n";
70 print "Final Size: $final\n";
72 if ( $final > $initial ) {
73 print "Leaked: " . ($final - $initial) . "K\n";
76 is( $final, $initial, "'$uri' memory is not leaking" );
82 foreach my $p ( @{ $t->table } ) {
83 if ( $p->pid == $pid ) {
88 die "Pid $pid not found?";