]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/ipc.t
ipc: fix IO::FDPass use with a worker limit of 1
[public-inbox.git] / t / ipc.t
diff --git a/t/ipc.t b/t/ipc.t
index f09f76ef740434b8b02c35a5640c890a91e5a127..fd2908095553b57bd33e9f9690f738d18e5449f2 100644 (file)
--- a/t/ipc.t
+++ b/t/ipc.t
@@ -121,7 +121,7 @@ $warn->autoflush(0);
 local $SIG{__WARN__} = sub { print $warn "PID:$$ ", @_ };
 my @ppids;
 for my $t ('local', 'worker', 'worker again') {
-       $ipc->wq_do('test_write_each_fd', $wa, $wb, $wc, 'hello world');
+       $ipc->wq_do('test_write_each_fd', [ $wa, $wb, $wc ], 'hello world');
        my $i = 0;
        for my $fh ($ra, $rb, $rc) {
                my $buf = readline($fh);
@@ -129,7 +129,7 @@ for my $t ('local', 'worker', 'worker again') {
                like($buf, qr/\Ai=$i \d+ hello world\z/, "got expected ($t)");
                $i++;
        }
-       $ipc->wq_do('test_die', $wa, $wb, $wc);
+       $ipc->wq_do('test_die', [ $wa, $wb, $wc ]);
        my $ppid = $ipc->wq_workers_start('wq', 1);
        push(@ppids, $ppid);
 }
@@ -142,7 +142,7 @@ SKIP: {
        my $pid = fork // BAIL_OUT $!;
        if ($pid == 0) {
                use POSIX qw(_exit);
-               $ipc->wq_do('test_write_each_fd', $wa, $wb, $wc, $$);
+               $ipc->wq_do('test_write_each_fd', [ $wa, $wb, $wc ], $$);
                _exit(0);
        } else {
                my $i = 0;
@@ -168,4 +168,21 @@ like($warn[0], qr/ wq_do: /, '1st warned from wq_do');
 like($warn[1], qr/ wq_worker: /, '2nd warned from wq_worker');
 is($warn[2], $warn[1], 'worker did not die');
 
+$SIG{__WARN__} = 'DEFAULT';
+is($ipc->wq_workers_start('wq', 1), $$, 'workers started again');
+is($ipc->wq_workers, 1, '1 worker started');
+SKIP: {
+       $ipc->WQ_MAX_WORKERS > 1 or
+               skip 'Inline::C or Socket::MsgHdr not available', 4;
+       $ipc->wq_worker_incr;
+       is($ipc->wq_workers, 2, 'worker count bumped');
+       $ipc->wq_worker_decr;
+       $ipc->wq_worker_decr_wait(10);
+       is($ipc->wq_workers, 1, 'worker count lowered');
+       is($ipc->wq_workers(2), 2, 'worker count set');
+       is($ipc->wq_workers, 2, 'worker count stayed set');
+}
+$ipc->wq_close;
+is($ipc->wq_workers, undef, 'workers undef after close');
+
 done_testing;