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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
package TestAPR::pool;
use strict;
use warnings FATAL => 'all';
use Apache::Test;
use Apache::TestUtil;
use Apache::TestTrace;
use Apache2::RequestRec ();
use APR::Pool ();
use APR::Table ();
use Apache2::Const -compile => 'OK';
use TestAPRlib::pool;
sub handler {
my $r = shift;
plan $r, tests => 4 + TestAPRlib::pool::num_of_tests();
### native pools ###
# explicit destroy shouldn't destroy native pools
{
my $p = $r->pool;
my $count = TestAPRlib::pool::ancestry_count($p);
t_debug "\$r->pool has 2 or more ancestors (found $count)";
ok $count >= 2;
$p->cleanup_register(\&set_cleanup, [$r, 'native destroy']);
$p->destroy;
my @notes = $r->notes->get('cleanup');
ok t_cmp(scalar(@notes), 0, "should be 0 notes");
$r->notes->clear;
}
# implicit DESTROY shouldn't destroy native pools
{
{
my $p = $r->pool;
my $count = TestAPRlib::pool::ancestry_count($p);
t_debug "\$r->pool has 2 or more ancestors (found $count)";
ok $count >= 2;
$p->cleanup_register(\&set_cleanup, [$r, 'native scoped']);
}
my @notes = $r->notes->get('cleanup');
ok t_cmp(scalar(@notes), 0, "should be 0 notes");
$r->notes->clear;
}
TestAPRlib::pool::test();
Apache2::Const::OK;
}
sub set_cleanup {
my $arg = shift;
debug "setting cleanup note: $arg->[1]";
$arg->[0]->notes->set(cleanup => $arg->[1]);
1;
}
1;
|