about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-17 23:38:02 +0000
committerEric Wong <e@80x24.org>2023-10-18 20:50:32 +0000
commit48aca3659c248c936a978a8338cf19aacc9483a1 (patch)
treef58abcee6960e6f479f79f5d03f57469d479d0ac /t
parent5406e15b4de72644e4bedb73029c94cad7af5d0a (diff)
downloadpublic-inbox-48aca3659c248c936a978a8338cf19aacc9483a1.tar.gz
We use this in various places to minimize or maximize pipe
size on Linux.  So keep it all in one place.
Diffstat (limited to 't')
-rw-r--r--t/gcf2.t5
-rw-r--r--t/lei-sigpipe.t7
2 files changed, 6 insertions, 6 deletions
diff --git a/t/gcf2.t b/t/gcf2.t
index d12a4420..33f3bbca 100644
--- a/t/gcf2.t
+++ b/t/gcf2.t
@@ -10,6 +10,7 @@ use POSIX qw(_exit);
 use Cwd qw(abs_path);
 require_mods('PublicInbox::Gcf2');
 use_ok 'PublicInbox::Gcf2';
+use PublicInbox::Syscall qw($F_SETPIPE_SZ);
 use PublicInbox::Import;
 my ($tmpdir, $for_destroy) = tmpdir();
 
@@ -109,7 +110,7 @@ SKIP: {
         for my $blk (1, 0) {
                 my ($r, $w);
                 pipe($r, $w) or BAIL_OUT $!;
-                fcntl($w, 1031, 4096) or
+                fcntl($w, $F_SETPIPE_SZ, 4096) or
                         skip('Linux too old for F_SETPIPE_SZ', 14);
                 $w->blocking($blk);
                 seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!";
@@ -129,7 +130,7 @@ SKIP: {
                 $ck_copying->("pipe blocking($blk)");
 
                 pipe($r, $w) or BAIL_OUT $!;
-                fcntl($w, 1031, 4096) or BAIL_OUT $!;
+                fcntl($w, $F_SETPIPE_SZ, 4096) or BAIL_OUT $!;
                 $w->blocking($blk);
                 close $r;
                 local $SIG{PIPE} = 'IGNORE';
diff --git a/t/lei-sigpipe.t b/t/lei-sigpipe.t
index 55c208e2..622598a4 100644
--- a/t/lei-sigpipe.t
+++ b/t/lei-sigpipe.t
@@ -6,6 +6,7 @@ use v5.10.1;
 use PublicInbox::TestCommon;
 use POSIX qw(WTERMSIG WIFSIGNALED SIGPIPE);
 use PublicInbox::OnDestroy;
+use PublicInbox::Syscall qw($F_SETPIPE_SZ);
 
 # undo systemd (and similar) ignoring SIGPIPE, since lei expects to be run
 # from an interactive terminal:
@@ -21,10 +22,8 @@ test_lei(sub {
         my $imported;
         for my $out ([], [qw(-f mboxcl2)], [qw(-f text)]) {
                 pipe(my ($r, $w)) or BAIL_OUT $!;
-                my $size = 65536;
-                if ($^O eq 'linux' && fcntl($w, 1031, 4096)) {
-                        $size = 4096;
-                }
+                my $size = $F_SETPIPE_SZ && fcntl($w, $F_SETPIPE_SZ, 4096) ?
+                        4096 : 65536;
                 unless (-f $f) {
                         open my $fh, '>', $f or xbail "open $f: $!";
                         print $fh <<'EOM' or xbail;