From: David Bremner <david@tethera.net>
To: "Rollins, Jameson" <jrollins@caltech.edu>,
Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH] test: add configurable port to smtp-dummy
Date: Mon, 6 May 2019 07:32:30 -0300 [thread overview]
Message-ID: <20190506103230.23669-1-david@tethera.net> (raw)
In-Reply-To: <20190506044406.6900-1-jrollins@caltech.edu>
This is to allow smtp-dummy to potentially be used from multiple T*.sh
without collisions during parallel test running.
---
test/T310-emacs.sh | 3 +++
test/smtp-dummy.c | 7 ++++++-
test/test-lib.sh | 4 +++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index c06a8133..3eab1ba9 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -5,6 +5,9 @@ test_description="emacs interface"
EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
+# this port must be unique to each test script using smtp-dummy
+export SMTP_DUMMY_PORT=25125
+
add_email_corpus
# syntax errors in test-lib.el cause mysterious failures
diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c
index 71992edd..4cd66f5c 100644
--- a/test/smtp-dummy.c
+++ b/test/smtp-dummy.c
@@ -120,6 +120,7 @@ int
main (int argc, char *argv[])
{
const char *progname;
+ const char *port_str;
char *output_filename;
FILE *peer_file = NULL, *output = NULL;
int sock = -1, peer, err;
@@ -191,7 +192,11 @@ main (int argc, char *argv[])
memset (&addr, 0, sizeof (addr));
addr.sin_family = AF_INET;
- addr.sin_port = htons (25025);
+ if ((port_str = getenv ("SMTP_DUMMY_PORT")))
+ addr.sin_port = htons (atoi (port_str));
+ else
+ addr.sin_port = htons (25025);
+
addr.sin_addr = *(struct in_addr *) hostinfo->h_addr;
err = bind (sock, (struct sockaddr *) &addr, sizeof (addr));
if (err) {
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 43339902..f3be537b 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -93,6 +93,8 @@ TEST_GDB=${TEST_GDB:-gdb}
TEST_CC=${TEST_CC:-cc}
TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}
+SMTP_DUMMY_PORT=${SMTP_DUMMY_PORT:-25025}
+
# Protect ourselves from common misconfiguration to export
# CDPATH into the environment
unset CDPATH
@@ -324,7 +326,7 @@ emacs_deliver_message ()
"(let ((message-send-mail-function 'message-smtpmail-send-it)
(mail-host-address \"example.com\")
(smtpmail-smtp-server \"localhost\")
- (smtpmail-smtp-service \"25025\"))
+ (smtpmail-smtp-service \"${SMTP_DUMMY_PORT}\"))
(notmuch-mua-mail)
(message-goto-to)
(insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\")
--
2.20.1
next prev parent reply other threads:[~2019-05-06 10:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-04 20:57 parallelize test suite Rollins, Jameson
2019-05-04 20:57 ` [PATCH 1/3] tests: remove some redundant pre-cleanup of the corpus MAIL_DIR Rollins, Jameson
2019-05-04 20:57 ` [PATCH 2/3] tests: remove entangling corpus index optimization Rollins, Jameson
2019-05-04 20:57 ` [PATCH 3/3] tests: run all tests in parallel, if available Rollins, Jameson
2019-05-06 4:44 ` [PATCH] tests: environment variable to specify that tests should be serialized Rollins, Jameson
2019-05-06 10:32 ` David Bremner [this message]
2019-05-06 19:39 ` [PATCH] test: add configurable port to smtp-dummy Tomi Ollila
2019-05-06 20:55 ` Daniel Kahn Gillmor
2019-05-07 10:20 ` [PATCH] test: let the OS choose a port for smtp-dummy David Bremner
2019-05-07 12:38 ` Daniel Kahn Gillmor
2019-05-08 15:59 ` Tomi Ollila
2019-05-10 10:16 ` David Bremner
2019-05-06 19:15 ` [PATCH] tests: environment variable to specify that tests should be serialized Tomi Ollila
2019-05-06 20:58 ` Daniel Kahn Gillmor
2019-05-05 10:22 ` [PATCH 1/3] tests: remove some redundant pre-cleanup of the corpus MAIL_DIR Tomi Ollila
2019-05-04 21:33 ` parallelize test suite Rollins, Jameson
2019-05-04 21:39 ` Daniel Kahn Gillmor
2019-05-04 22:53 ` David Bremner
2019-05-05 15:22 ` Daniel Kahn Gillmor
2019-05-05 16:44 ` Tomi Ollila
2019-05-06 21:39 ` Daniel Kahn Gillmor
2019-05-07 10:26 ` David Bremner
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://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190506103230.23669-1-david@tethera.net \
--to=david@tethera.net \
--cc=jrollins@caltech.edu \
--cc=notmuch@notmuchmail.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://yhetil.org/notmuch.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).