4 # T::M appears to leak, emit the TAP by hand
5 #use Test::More 'no_plan';
8 my $str = $_[0] eq $_[1] ? 'ok' : 'not ok';
13 printf STDOUT ("%s %u - %s\n",
19 printf STDERR ("# Failed test #%d at %s line %d
23 " , $::TEST_COUNT, (caller(0))[1,2],
24 , (map { unpack 'H*', $_ } @_[0,1])
29 threads->yield if $INC{'threads.pm'};
32 use Devel::PeekPoke qw/peek poke/;
33 use Devel::PeekPoke::Constants qw/PTR_SIZE PTR_PACK_TYPE/;
35 my $str = 'for mutilation and mayhem';
36 my $len = length($str);
37 my $str_pv_addr = unpack(PTR_PACK_TYPE, pack('p', $str) );
39 is( peek($str_pv_addr, $len + 1), $str . "\0", 'peek as expected (with NUL termination)' );
41 for (1 .. ($ENV{AUTOMATED_TESTING} ? 200 : 5 ) ) {
42 for my $poke_size (2 .. $len) {
43 my $replace_chunk = 'a' . ( '0' x ($poke_size-1) );
44 for my $poke_start ( 0 .. ($len - $poke_size) ) {
48 substr($expecting, $poke_start, $poke_size, $replace_chunk);
50 poke($str_pv_addr+$poke_start, $replace_chunk);
51 is($str, $expecting, 'String matches expectation after poke');
56 if ($ENV{AUTOMATED_TESTING} and ! $INC{'threads.pm'}) {
58 if (-f "/proc/$$/stat") {
59 my $proc_stat = do { local (@ARGV, $/) = "/proc/$$/stat"; <> };
60 ($vsz) = map { $_ / 1024 }
61 (split (/\s+/, $proc_stat))[-22]; # go backwards because the %s of the procname can contain anything
64 printf STDERR "#\n# VSIZE:%dKiB\n", $vsz
68 print "1..$::TEST_COUNT\n" unless $INC{'threads.pm'};