From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/2] tests: maintainer test for using mpop
Date: Fri, 29 Jul 2022 20:41:04 +0000 [thread overview]
Message-ID: <20220729204104.8563-3-e@80x24.org> (raw)
In-Reply-To: <20220729204104.8563-1-e@80x24.org>
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 <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+# 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 <<EOF or xbail "print: $!";
+[publicinbox]
+ pop3state = $tmpdir/p3s
+[publicinbox "test"]
+ newsgroup = $newsgroup
+ address = mpop-test\@example.com
+ inboxdir = $inboxdir
+EOF
+ close $fh or xbail "close: $!";
+}
+my ($out, $err) = ("$tmpdir/stdout.log", "$tmpdir/stderr.log");
+my $sock = tcp_server();
+my $cmd = [ '-pop3d', '-W0', "--stdout=$out", "--stderr=$err" ];
+my $env = { PI_CONFIG => $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 <<EOM or xbail "print $!";
+defaults
+tls off
+delivery maildir $tmpdir/md
+account default
+host ${\$sock->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;
prev parent reply other threads:[~2022-07-29 20:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 20:41 [PATCH 0/2] POP3 docs + tests for users and BOFHs Eric Wong
2022-07-29 20:41 ` [PATCH 1/2] doc|www: flesh out POP3 documentation for servers and users Eric Wong
2023-02-06 6:03 ` POP3 adoption (was: [PATCH 1/2] doc|www: flesh out POP3 documentation for servers) " Eric Wong
2023-02-06 14:27 ` Konstantin Ryabitsev
2022-07-29 20:41 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220729204104.8563-3-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).