]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
t/xap_helper: skip test if missing SCM_RIGHTS support
authorEric Wong <e@80x24.org>
Sat, 26 Aug 2023 20:14:04 +0000 (20:14 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Aug 2023 00:27:00 +0000 (00:27 +0000)
xap_helper currently relies on FDs passed via SCM_RIGHTS for
robustness against $TMPDIR failures and over-eager FS cleanup
tasks.  This depends on stable syscall numbers (Linux) or
Inline::C||Socket::MsgHdr being available, though, as Perl5
itself doesn't support SCM_RIGHTS.

We could probably add FIFO support to xap_helper for portability
to systems where neither Inline::C nor Socket::MsgHdr are available,
but that's for another day.

lib/PublicInbox/TestCommon.pm
t/xap_helper.t

index ddee58b1ee853d240b589b279140bcb167a0690f..6da993af8ac166365b3aab44bc52f262054bb3ed 100644 (file)
@@ -22,7 +22,7 @@ BEGIN {
        @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods
                run_script start_script key2sub xsys xsys_e xqx eml_load tick
                have_xapian_compact json_utf8 setup_public_inboxes create_inbox
-               create_coderepo
+               create_coderepo no_scm_rights
                tcp_host_port test_lei lei lei_ok $lei_out $lei_err $lei_opt
                test_httpd xbail require_cmd is_xdeeply tail_f
                ignore_inline_c_missing);
@@ -567,6 +567,16 @@ sub ignore_inline_c_missing {
                grep(!/\bInline\b/, split(/^/m, $_[0])))));
 }
 
+sub no_scm_rights () {
+       state $ok = PublicInbox::Spawn->can('send_cmd4') || do {
+                       require PublicInbox::Syscall;
+                       PublicInbox::Syscall->can('send_cmd4');
+               } || eval { require Socket::MsgHdr; 1 };
+       return if $ok;
+       'Inline::C unconfigured/missing '.
+       '(mkdir -p ~/.cache/public-inbox/inline-c) OR Socket::MsgHdr missing';
+}
+
 sub test_lei {
 SKIP: {
        my ($cb) = pop @_;
@@ -591,15 +601,8 @@ SKIP: {
        $ENV{LANG} = $ENV{LC_ALL} = 'C';
        my (undef, $fn, $lineno) = caller(0);
        my $t = "$fn:$lineno";
-       state $lei_daemon = PublicInbox::Spawn->can('send_cmd4') || do {
-                       require PublicInbox::Syscall;
-                       PublicInbox::Syscall->can('send_cmd4');
-               } || eval { require Socket::MsgHdr; 1 };
-       unless ($lei_daemon) {
-               skip('Inline::C unconfigured/missing '.
-'(mkdir -p ~/.cache/public-inbox/inline-c) OR Socket::MsgHdr missing',
-                       1);
-       }
+       state $msg = no_scm_rights();
+       skip $msg, 1 if $msg;
        $lei_opt = { 1 => \$lei_out, 2 => \$lei_err };
        my ($daemon_pid, $for_destroy, $daemon_xrd);
        my $tmpdir = $test_opt->{tmpdir};
index 92da2e6d1edcf23a572d85bbabe86a6c8ee5789b..3646cf9786ee5d4dd411cdfa7821bb97ddb83205 100644 (file)
@@ -4,6 +4,8 @@
 use v5.12;
 use PublicInbox::TestCommon;
 require_mods(qw(DBD::SQLite Search::Xapian));
+my $msg = no_scm_rights;
+plan(skip_all => $msg) if $msg; # TODO: FIFO support?
 use PublicInbox::Spawn qw(spawn);
 use Socket qw(AF_UNIX SOCK_SEQPACKET SOCK_STREAM MSG_EOR);
 require PublicInbox::AutoReap;