1 # This was discussed here:
2 # http://groups.google.com/group/DBM-Deep/browse_thread/thread/a6b8224ffec21bab
3 # brought up by Alex Gallichotte
6 use warnings FATAL => 'all';
10 plan skip_all => "Need to figure out what platforms this runs on";
12 use_ok( 'DBM::Deep' );
14 use t::common qw( new_dbm );
16 my $dbm_factory = new_dbm();
17 while ( my $dbm_maker = $dbm_factory->() ) {
18 my $db = $dbm_maker->();
21 my $allow = $todo*0.02; # NOTE: a 2% fail rate is hardly a failure
23 $db->{randkey()} = 1 for 1 .. 1000;
26 my @mem = (mem(0), mem(1));
27 for my $i (1 .. $todo) {
28 $db->{randkey()} = [@mem];
30 ## DEBUG ## print STDERR " @mem \r";
32 my @tm = (mem(0), mem(1));
34 skip( not($mem[0]), ($tm[0] <= $mem[0] or --$allow>0) );
35 skip( not($mem[1]), ($tm[1] <= $mem[1] or --$allow>0) );
37 $error_count ++ if $tm[0] > $mem[0] or $tm[1] > $mem[1];
38 die " ERROR: that's enough failures to prove the point ... " if $error_count > 20;
46 my @k = map { int rand 100 } 1 .. 10;
53 open my $in, "/proc/$$/statm" or return 0;
54 my $line = [ split m/\s+/, <$in> ];
57 return $line->[shift];
63 Provides information about memory status in pages. The columns are:
65 size total program size
66 resident resident set size
71 dt dirty pages (unused in Linux 2.6)