about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-24 04:46:48 -0700
committerEric Wong <e@80x24.org>2021-01-24 15:45:21 -0400
commit509c88ddfe0bb3bf4f00ff119eb2d847512df90c (patch)
treec9d34db00ab571afee20b203013ccc2dcb40a26d /t
parent0ca8bd671784ffd1a4ed59914e0b9a0bef7c0ea5 (diff)
downloadpublic-inbox-509c88ddfe0bb3bf4f00ff119eb2d847512df90c.tar.gz
This should not be needed, but somebody using lei could
theoretically create thousands of external URLs and
only have a handful of workers, which means the per-worker
URI list could be large.
Diffstat (limited to 't')
-rw-r--r--t/cmd_ipc.t16
-rw-r--r--t/ipc.t22
2 files changed, 37 insertions, 1 deletions
diff --git a/t/cmd_ipc.t b/t/cmd_ipc.t
index 96510175..84f8fb4d 100644
--- a/t/cmd_ipc.t
+++ b/t/cmd_ipc.t
@@ -82,6 +82,22 @@ my $do_test = sub { SKIP: {
                 @fds = $recv->($s2, $buf, length($src));
                 is(scalar(@fds), 0, 'no FDs received');
                 is($buf, $src, 'recv w/o FDs');
+
+                my $nr = 2 * 1024 * 1024;
+                while (1) {
+                        vec(my $vec = '', $nr * 8 - 1, 1) = 1;
+                        my $n = $send->($s1, [], $vec, $flag);
+                        if (defined($n)) {
+                                $n == length($vec) or
+                                        fail "short send: $n != ".length($vec);
+                                diag "sent $nr, retrying with more";
+                                $nr += 2 * 1024 * 1024;
+                        } else {
+                                ok($!{EMSGSIZE}, 'got EMSGSIZE');
+                                # diag "$nr bytes hits EMSGSIZE";
+                                last;
+                        }
+                }
         }
 } };
 
diff --git a/t/ipc.t b/t/ipc.t
index 22423a78..f25f2491 100644
--- a/t/ipc.t
+++ b/t/ipc.t
@@ -6,11 +6,13 @@ use v5.10.1;
 use Test::More;
 use PublicInbox::TestCommon;
 use Fcntl qw(SEEK_SET);
+use Digest::SHA qw(sha1_hex);
 require_mods(qw(Storable||Sereal));
 require_ok 'PublicInbox::IPC';
 state $once = eval <<'';
 package PublicInbox::IPC;
 use strict;
+use Digest::SHA qw(sha1_hex);
 sub test_array { qw(test array) }
 sub test_scalar { 'scalar' }
 sub test_scalarref { \'scalarref' }
@@ -24,6 +26,11 @@ sub test_write_each_fd {
                 $self->{$fd}->flush;
         }
 }
+sub test_sha {
+        my ($self, $buf) = @_;
+        print { $self->{1} } sha1_hex($buf), "\n";
+        $self->{1}->flush;
+}
 1;
 
 my $ipc = bless {}, 'PublicInbox::IPC';
@@ -112,7 +119,7 @@ $test->('local');
 $ipc->ipc_worker_stop; # idempotent
 
 # work queues
-$ipc->wq_set_recv_modes(qw( >&= >&= >&= ));
+$ipc->wq_set_recv_modes(qw( +>&= >&= >&= ));
 pipe(my ($ra, $wa)) or BAIL_OUT $!;
 pipe(my ($rb, $wb)) or BAIL_OUT $!;
 pipe(my ($rc, $wc)) or BAIL_OUT $!;
@@ -120,6 +127,10 @@ open my $warn, '+>', undef or BAIL_OUT;
 $warn->autoflush(0);
 local $SIG{__WARN__} = sub { print $warn "PID:$$ ", @_ };
 my @ppids;
+open my $agpl, '<', 'COPYING' or BAIL_OUT "AGPL-3 missing: $!";
+my $big = do { local $/; <$agpl> } // BAIL_OUT "read: $!";
+close $agpl or BAIL_OUT "close: $!";
+
 for my $t ('local', 'worker', 'worker again') {
         $ipc->wq_do('test_write_each_fd', [ $wa, $wb, $wc ], 'hello world');
         my $i = 0;
@@ -130,6 +141,15 @@ for my $t ('local', 'worker', 'worker again') {
                 $i++;
         }
         $ipc->wq_do('test_die', [ $wa, $wb, $wc ]);
+        $ipc->wq_do('test_sha', [ $wa, $wb ], 'hello world');
+        is(readline($rb), sha1_hex('hello world')."\n", "SHA small ($t)");
+        {
+                my $bigger = $big x 10;
+                $ipc->wq_do('test_sha', [ $wa, $wb ], $bigger);
+                my $exp = sha1_hex($bigger)."\n";
+                undef $bigger;
+                is(readline($rb), $exp, "SHA big ($t)");
+        }
         my $ppid = $ipc->wq_workers_start('wq', 1);
         push(@ppids, $ppid);
 }