From: Peter Rabbitson Date: Mon, 6 Feb 2012 08:49:29 +0000 (+0100) Subject: More stress testing and switch away from Test::More - the POS leaks >:( X-Git-Tag: v0.02~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b733ba16504382fc5e5d765ccf5a4f405ea3933;p=p5sagit%2FDevel-PeekPoke.git More stress testing and switch away from Test::More - the POS leaks >:( Add a simple nonportable memory meter --- diff --git a/t/03torture.t b/t/03torture.t index 05247f0..13d80ea 100644 --- a/t/03torture.t +++ b/t/03torture.t @@ -1,7 +1,18 @@ use strict; use warnings; -use Test::More; +# T::M appears to leak, emit the TAP by hand +#use Test::More 'no_plan'; + +my $tests = 0; +sub is { + $tests++; + printf("%s %u - %s\n", + ( $_[0] eq $_[1] ? 'ok' : 'not ok' ), + $tests, + $_[2] || '', + ); +} use Devel::PeekPoke qw/peek poke peek_address poke_address/; use Devel::PeekPoke::Constants qw/PTR_SIZE PTR_PACK_TYPE/; @@ -12,17 +23,31 @@ my $str_pv_addr = unpack(PTR_PACK_TYPE, pack('p', $str) ); is( peek($str_pv_addr, $len + 1), $str . "\0", 'peek as expected (with NUL termination)' ); -for my $poke_size (2 .. $len) { - my $replace_chunk = 'a' . ( '0' x ($poke_size-1) ); - for my $poke_start ( 0 .. ($len - $poke_size) ) { - $replace_chunk++; +for (1 .. ($ENV{AUTOMATED_TESTING} ? 300 : 20) ) { + for my $poke_size (2 .. $len) { + my $replace_chunk = 'a' . ( '0' x ($poke_size-1) ); + for my $poke_start ( 0 .. ($len - $poke_size) ) { + $replace_chunk++; - my $expecting = $str; - substr($expecting, $poke_start, $poke_size, $replace_chunk); + my $expecting = $str; + substr($expecting, $poke_start, $poke_size, $replace_chunk); - poke($str_pv_addr+$poke_start, $replace_chunk); - is($str, $expecting, 'String matches expectation after poke'); + poke($str_pv_addr+$poke_start, $replace_chunk); + is($str, $expecting, 'String matches expectation after poke'); + } } } -done_testing; +if ($ENV{AUTOMATED_TESTING}) { + my $vsz; + if (-f "/proc/$$/stat") { + my $proc_stat = do { local (@ARGV, $/) = "/proc/$$/stat"; <> }; + ($vsz) = map { $_ / 1024 } + (split (/\s+/, $proc_stat))[-22]; # go backwards because the %s of the procname can contain anything + } + + printf STDERR "#\n# VSIZE:%dKiB\n", $vsz + if $vsz; +} + +print "1..$tests\n";