diff options
author | Eric Wong <e@80x24.org> | 2023-01-11 01:12:48 +0000 |
---|---|---|
committer | Eric Wong <mwrap-perl@80x24.org> | 2023-01-11 04:23:31 +0000 |
commit | 64a55ae0ba1d09ccda458eb895d849e7d38cab81 (patch) | |
tree | 10f5f5d99c49de5ba17277540a786a477f9e9c5c /t | |
parent | 86d350a3854af1a5a292972d4f70154e61ce5e80 (diff) | |
download | mwrap-64a55ae0ba1d09ccda458eb895d849e7d38cab81.tar.gz |
%p => PID expansion for dump_path + dump_csv
This makes it possible to dump per-PID files for processes which fork. `%p' matches what the Linux sys.kernel.core_pattern sysctl understands.
Diffstat (limited to 't')
-rw-r--r-- | t/mwrap.t | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -42,6 +42,21 @@ my $dump = "$mwrap_tmp/dump"; $nr_comma = ($s =~ tr/,/,/); $nr_cr = ($s =~ tr/\n/\n/); ok($nr_comma > ($nr_cr * 4), 'CSV has more commas than CR'); + + $env->{MWRAP} = "dump_path:$dump.%p"; + mwrap_run('dump_path PID expansion', $env, '-e', $script); + my @d = grep(/\.\d+\z/, glob("$dump.*")); + is(scalar(@d), 1, 'got PID file') or diag explain([glob("$dump*")]); + unlink(@d) or BAIL_OUT "unlink: $!"; + + # don't allow injecting random formats + for my $fmt ('%p.%m', '%m.%p') { + my $fn = $dump.$fmt; + $env->{MWRAP} = "dump_path:$fn"; + mwrap_run("PID expansion fails on $fmt", $env, '-e', $script); + ok($fn, "$fmt used as-is"); + unlink($fn) or BAIL_OUT "unlink: $!"; + } } SKIP: { # C++ program which uses malloc via "new" |