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 threads->yield if $INC{'threads.pm'};
22 use Devel::PeekPoke qw/peek poke peek_address poke_address/;
23 use Devel::PeekPoke::Constants qw/PTR_SIZE PTR_PACK_TYPE/;
25 my $str = 'for mutilation and mayhem';
26 my $len = length($str);
27 my $str_pv_addr = unpack(PTR_PACK_TYPE, pack('p', $str) );
29 is( peek($str_pv_addr, $len + 1), $str . "\0", 'peek as expected (with NUL termination)' );
31 for (1 .. ($ENV{AUTOMATED_TESTING} ? 200 : 20 ) ) {
32 for my $poke_size (2 .. $len) {
33 my $replace_chunk = 'a' . ( '0' x ($poke_size-1) );
34 for my $poke_start ( 0 .. ($len - $poke_size) ) {
38 substr($expecting, $poke_start, $poke_size, $replace_chunk);
40 poke($str_pv_addr+$poke_start, $replace_chunk);
41 is($str, $expecting, 'String matches expectation after poke');
46 if ($ENV{AUTOMATED_TESTING} and ! $INC{'threads.pm'}) {
48 if (-f "/proc/$$/stat") {
49 my $proc_stat = do { local (@ARGV, $/) = "/proc/$$/stat"; <> };
50 ($vsz) = map { $_ / 1024 }
51 (split (/\s+/, $proc_stat))[-22]; # go backwards because the %s of the procname can contain anything
54 printf STDERR "#\n# VSIZE:%dKiB\n", $vsz
58 print "1..$::TEST_COUNT\n" unless $INC{'threads.pm'};