7 use lib "$FindBin::Bin/../live/lib";
10 use Catalyst::Test 'TestApp';
14 plan skip_all => 'set TEST_MEMLEAK to enable this test'
15 unless $ENV{TEST_MEMLEAK};
16 plan skip_all => 'GTop required for this test' if $@;
18 our $gtop = GTop->new;
19 our ( $initial, $final ) = ( 0, 0 );
20 our $tests = YAML::LoadFile("$FindBin::Bin/stress.yml");
24 # let the user specify a single uri to test
25 my $user_test = shift;
28 run_test( $user_test );
30 # otherwise, run all tests
32 map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
33 plan tests => $total_tests;
35 foreach my $test_group ( keys %{$tests} ) {
36 foreach my $test ( @{ $tests->{$test_group} } ) {
43 my $uri = shift || die 'No URI given for test';
45 print "TESTING $uri\n";
47 # make a few requests to set initial memory size
52 $initial = $gtop->proc_mem($$)->size;
53 print "Initial Size: " . GTop::size_string($initial) . "\n";
59 $final = $gtop->proc_mem($$)->size;
60 print "Final Size: " . GTop::size_string($final) . "\n";
62 if ( $final > $initial ) {
63 print "Leaked Bytes: " . GTop::size_string($final - $initial) . "\n";
66 is( $final, $initial, "'$uri' memory is not leaking" );