]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/ipc.t
ipc: wq_do: support synchronous waits and responses
[public-inbox.git] / t / ipc.t
diff --git a/t/ipc.t b/t/ipc.t
index ca88eb59d4ed8fe4dc16fcd2d24ea7c973e060c6..202b1cc658df533b1a52b44676a19389808081a5 100644 (file)
--- a/t/ipc.t
+++ b/t/ipc.t
@@ -122,11 +122,16 @@ for my $t ('local', 'worker', 'worker again') {
        $ipc->wq_io_do('test_sha', [ $wa, $wb ], 'hello world');
        is(readline($rb), sha1_hex('hello world')."\n", "SHA small ($t)");
        {
-               my $bigger = $big x 10;
+               my $bigger = $big x 10; # to hit EMSGSIZE
                $ipc->wq_io_do('test_sha', [ $wa, $wb ], $bigger);
                my $exp = sha1_hex($bigger)."\n";
-               undef $bigger;
-               is(readline($rb), $exp, "SHA big ($t)");
+               is(readline($rb), $exp, "SHA big for EMSGSIZE ($t)");
+
+               # to hit the WQWorker recv_and_run length
+               substr($bigger, my $MY_MAX_ARG_STRLEN = 4096 * 33, -1) = '';
+               $ipc->wq_io_do('test_sha', [ $wa, $wb ], $bigger);
+               $exp = sha1_hex($bigger)."\n";
+               is(readline($rb), $exp, "SHA WQWorker limit ($t)");
        }
        my $ppid = $ipc->wq_workers_start('wq', 1);
        push(@ppids, $ppid);
@@ -156,6 +161,12 @@ SKIP: {
                is(waitpid($pid, 0), $pid, 'waitpid complete');
                is($?, 0, 'child wq producer exited');
        }
+       my @ary = $ipc->wq_do('test_array');
+       is_deeply(\@ary, [ qw(test array) ], 'wq_do wantarray');
+       is(my $s = $ipc->wq_do('test_scalar'), 'scalar', 'defined wantarray');
+       my $exp = bless ['blessed'], 'PublicInbox::WTF';
+       my $ret = eval { $ipc->wq_do('test_die', $exp) };
+       is_deeply($@, $exp, 'die with blessed ref');
 }
 
 $ipc->wq_close;