diff options
author | Eric Wong <e@80x24.org> | 2019-06-10 09:52:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-10 09:52:13 +0000 |
commit | f5795a6092d6b4842e97bc67c11637d792961cb5 (patch) | |
tree | 30eada9950c7fbb745003645f41205fb0169f253 /t/malloc_info.t | |
parent | c44825f8b2f3d57f6aca29d75516db8712261954 (diff) | |
download | public-inbox-f5795a6092d6b4842e97bc67c11637d792961cb5.tar.gz |
If run with PERL_INLINE_DIRECTORY for Inline::C support along with INBOX_DEBUG=malloc_info, we can allow users to opt-in to compiling extra code to support the glibc malloc_info(3) function. We'll also add SIGCONT handler to dump the malloc_info(3) output to stderr on our daemons.
Diffstat (limited to 't/malloc_info.t')
-rw-r--r-- | t/malloc_info.t | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/t/malloc_info.t b/t/malloc_info.t new file mode 100644 index 00000000..352ec5cf --- /dev/null +++ b/t/malloc_info.t @@ -0,0 +1,25 @@ +# Copyright (C) 2019 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> +use strict; +use warnings; +use Test::More; +use PublicInbox::Spawn (); + +if (!PublicInbox::Spawn->can('inbox_malloc_info')) { + plan skip_all => 'inbox_malloc_info not enabled'; +} + +open my $olderr, '>&', \*STDERR or die "dup stderr: $!"; +open my $tmp, '+>', undef or die "tmpfile: $!"; +open STDERR, '>&', $tmp or die "redirect stderr to \$tmp: $!"; +my @x = map { '0' x (1024 * 1024) } (1..128); +my $cb = $SIG{CONT}; +$cb->(); +@x = ('hello'); +PublicInbox::Spawn::inbox_malloc_info(0); +open STDERR, '>&', $olderr or die "restore stderr: $!"; +sysseek($tmp, 0, 0) == 0 or die "sysseek: $!"; +my @info = <$tmp>; +like($info[0], qr/</, 'output looks like XML'); + +done_testing; |