From: Andy Grundman Date: Wed, 26 Oct 2005 19:19:27 +0000 (+0000) Subject: Combined memleak test with stress test to test all test actions X-Git-Tag: 5.7099_04~1098 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=010c814d7378030f1255c2cd038653d34074ecd6 Combined memleak test with stress test to test all test actions --- diff --git a/t/optional/memleak.t b/t/optional/memleak.t index 9731bb7..d5de6ff 100644 --- a/t/optional/memleak.t +++ b/t/optional/memleak.t @@ -8,32 +8,51 @@ use lib "$FindBin::Bin/../live/lib"; use Test::More; use Catalyst::Test 'TestApp'; +use YAML; eval "use GTop"; plan skip_all => 'set TEST_MEMLEAK to enable this test' unless $ENV{TEST_MEMLEAK}; plan skip_all => 'GTop required for this test' if $@; -plan tests => 1; +our $gtop = GTop->new; +our ( $initial, $final ) = ( 0, 0 ); +our $tests = YAML::LoadFile("$FindBin::Bin/stress.yml"); -{ - # make a request to set initial memory size - request('http://localhost'); +my $total_tests = 0; +map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests}; +plan tests => $total_tests; + +foreach my $test_group ( keys %{$tests} ) { + foreach my $test ( @{ $tests->{$test_group} } ) { + run_test( $test ); + } +} + +sub run_test { + my $uri = shift || die 'No URI given for test'; - my $gtop = GTop->new; - my $initial = $gtop->proc_mem($$)->size; + print "TESTING $uri\n"; + + # make a few requests to set initial memory size + for ( 1 .. 3 ) { + request( $uri ); + } + + $initial = $gtop->proc_mem($$)->size; print "Initial Size: " . GTop::size_string($initial) . "\n"; - for ( 1 .. 1000 ) { - request('http://localhost'); + for ( 1 .. 500 ) { + request( $uri ); } - my $final = $gtop->proc_mem($$)->size; + $final = $gtop->proc_mem($$)->size; print "Final Size: " . GTop::size_string($final) . "\n"; if ( $final > $initial ) { print "Leaked Bytes: " . GTop::size_string($final - $initial) . "\n"; } - is( $final, $initial, 'memory is not leaking' ); + is( $final, $initial, "'$uri' memory is not leaking" ); } +