1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
package TestApache::zzz_check_n_requests;
use strict;
use warnings;
use Apache::Constants;
use Apache::Test qw(-withtestmore);
use Apache::TestUtil;
use Apache::SizeLimit;
use constant ONE_MB => 1024;
use constant TEN_MB => ONE_MB * 10;
use constant TWENTY_MB => TEN_MB * 2;
my $i = 0;
my %hash = ();
sub handler {
my $r = shift;
plan $r, tests => 11;
Apache::SizeLimit->add_cleanup_handler($r);
Apache::SizeLimit->set_max_process_size(TEN_MB);
## this should cause us to fire
Apache::SizeLimit->set_check_interval();
# We can assume this will use _at least_ 1MB of memory, based on
# assuming a scalar consumes >= 1K.
# and after 10 requests, we should be _at least_ 10MB of memory
for (0..9) {
my @big = ('x') x ONE_MB;
$hash{$i++} = \@big;
is(
$i,
$i,
"now using $i MB of memory (at least)"
);
}
is(
1,
Apache::SizeLimit->_limits_are_exceeded(),
"we passed the limits and _WILL_ kill the child"
);
return Apache::Constants::OK;
}
1;
|