From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id CDC8F1F61C for ; Fri, 29 Jul 2022 20:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1659127264; bh=kzw0i0VSoAriih+1cdBkJHeTtt3Qgnps+ulcfimRum8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=E6smR7XmUkVC+qJMFBj7EQQNweqciz8DF+WW20k1uuGnN9faT6pUGwjw5SS6v2cuV 6xc9FUFyB4lAIamzgHzrYkZNwRXhksY5XZMcfLECD/+VQPkf9R0+EemxOABCBnGAPh dU1Wk5A8a+85W0bwphkSs1Dfvr5BfAmPrMcS0G+E= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] tests: maintainer test for using mpop Date: Fri, 29 Jul 2022 20:41:04 +0000 Message-Id: <20220729204104.8563-3-e@80x24.org> In-Reply-To: <20220729204104.8563-1-e@80x24.org> References: <20220729204104.8563-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This ought to be a good stress test to ensure our POP3 implementation works against the POP3 client I've found. --- MANIFEST | 1 + xt/pop3d-mpop.t | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 xt/pop3d-mpop.t diff --git a/MANIFEST b/MANIFEST index ce5e08a7..dac6875e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -605,5 +605,6 @@ xt/perf-msgview.t xt/perf-nntpd.t xt/perf-obfuscate.t xt/perf-threading.t +xt/pop3d-mpop.t xt/solver.t xt/stress-sharedkv.t diff --git a/xt/pop3d-mpop.t b/xt/pop3d-mpop.t new file mode 100644 index 00000000..8648b953 --- /dev/null +++ b/xt/pop3d-mpop.t @@ -0,0 +1,77 @@ +#!perl -w +# Copyright (C) all contributors +# License: AGPL-3.0+ +# ensure mpop compatibility +use v5.12; +use File::Path qw(make_path); +use PublicInbox::TestCommon; +use PublicInbox::Spawn qw(which spawn); +my $inboxdir = $ENV{GIANT_INBOX_DIR}; +(defined($inboxdir) && -d $inboxdir) or + plan skip_all => "GIANT_INBOX_DIR not defined for $0"; +plan skip_all => "bad characters in $inboxdir" if $inboxdir =~ m![^\w\.\-/]!; +my $uuidgen = which('uuidgen') or plan skip_all => 'uuidgen(1) missing'; +require_mods(qw(DBD::SQLite)); +require_git('2.6'); # for v2 +require_mods(qw(File::FcntlLock)) if $^O !~ /\A(?:linux|freebsd)\z/; + +my ($tmpdir, $for_destroy) = tmpdir(); +my $cfg = "$tmpdir/cfg"; +my $newsgroup = 'inbox.test'; +my %pids; +{ + open my $fh, '>', $cfg or xbail "open: $!"; + print $fh < $cfg }; +my $td = start_script($cmd, $env, { 3 => $sock }) or xbail "-xbail $?"; +chomp(my $uuid = xqx([$uuidgen])); + +make_path("$tmpdir/home/.config/mpop", + map { "$tmpdir/md/$_" } qw(new cur tmp)); + +SKIP: { + my $mpop = which('mpop') or skip('mpop(1) missing', 1); + open my $fh, '>', "$tmpdir/home/.config/mpop/config" + or xbail "open $!"; + chmod 0600, $fh; + print $fh <sockhost} +port ${\$sock->sockport} +user $uuid\@$newsgroup +auth user +password anonymous +received_header off +EOM + close $fh or xbail "close $!"; + delete local $ENV{XDG_CONFIG_HOME}; # mpop uses this + local $ENV{HOME} = "$tmpdir/home"; + my $cmd = [ $mpop, '-q' ]; + my $pid = spawn($cmd, undef, { 1 => 2 }); + $pids{$pid} = $cmd; +} + +while (scalar keys %pids) { + my $pid = waitpid(-1, 0) or next; + my $cmd = delete $pids{$pid} or next; + is($?, 0, join(' ', @$cmd, 'done')); +} +$td->kill; +$td->join; +is($?, 0, 'no error on -pop3d exit'); +done_testing;