diff options
author | Eric Wong <e@80x24.org> | 2018-12-26 09:07:49 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-12-29 03:45:37 +0000 |
commit | 59c946a014f34cd90621b1fb3b30af99ba80bf61 (patch) | |
tree | 194643ecd5d2388dbfd62a4503842f03c414be13 /t/perf-nntpd.t | |
parent | 2b5da4383d9c6defd2d473bf02eb8920bd589890 (diff) | |
download | public-inbox-59c946a014f34cd90621b1fb3b30af99ba80bf61.tar.gz |
IPC::Run provides a nice simplification in several places; and we already use it (optionally) on a lot of tests. For the non-test code, we still rely on our vfork-capable Inline::C stuff since real-world server processes can get large enough to where vfork is an advantage. Maybe Perl5 can use CLONE_VFORK somehow, one day: https://rt.perl.org/Ticket/Display.html?id=128227 Ohg V'q engure cbeg choyvp-vaobk gb Ehol :C
Diffstat (limited to 't/perf-nntpd.t')
-rw-r--r-- | t/perf-nntpd.t | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/t/perf-nntpd.t b/t/perf-nntpd.t index f7890d1c..3ca1ce33 100644 --- a/t/perf-nntpd.t +++ b/t/perf-nntpd.t @@ -6,13 +6,13 @@ use Test::More; use Benchmark qw(:all :hireswallclock); use PublicInbox::Inbox; use File::Temp qw/tempdir/; -use POSIX qw(dup2); -use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD); use Net::NNTP; my $pi_dir = $ENV{GIANT_PI_DIR}; plan skip_all => "GIANT_PI_DIR not defined for $0" unless $pi_dir; eval { require PublicInbox::Search }; my ($host_port, $group, %opts, $s, $pid); +require './t/common.perl'; + END { if ($s) { $s->print("QUIT\r\n"); @@ -53,21 +53,8 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) { my $sock = IO::Socket::INET->new(%opts); ok($sock, 'sock created'); - $! = 0; - $pid = fork; - if ($pid == 0) { - # pretend to be systemd - my $fl = fcntl($sock, F_GETFD, 0); - dup2(fileno($sock), 3) or die "dup2 failed: $!\n"; - dup2(1, 2) or die "dup2 failed: $!\n"; - fcntl($sock, F_SETFD, $fl &= ~FD_CLOEXEC); - $ENV{LISTEN_PID} = $$; - $ENV{LISTEN_FDS} = 1; - $ENV{PI_CONFIG} = $pi_config; - exec $nntpd, '-W0'; - die "FAIL: $!\n"; - } - ok(defined $pid, 'forked nntpd process successfully'); + my $cmd = [ $nntpd, '-W0' ]; + $pid = spawn_listener({ PI_CONFIG => $pi_config }, $cmd, [$sock]); $host_port = $sock->sockhost . ':' . $sock->sockport; } %opts = ( |