mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 17:34:54 +01:00
test: let the OS choose a port for smtp-dummy
This should avoid potential collisions if we start running multiple smtp-dummy processes in parallel.
This commit is contained in:
parent
e1c8357c44
commit
f2425a11a3
2 changed files with 15 additions and 2 deletions
|
@ -129,6 +129,7 @@ main (int argc, char *argv[])
|
|||
int reuse;
|
||||
int background;
|
||||
int ret = 0;
|
||||
socklen_t addrlen;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
|
@ -191,7 +192,7 @@ main (int argc, char *argv[])
|
|||
|
||||
memset (&addr, 0, sizeof (addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons (25025);
|
||||
addr.sin_port = 0;
|
||||
addr.sin_addr = *(struct in_addr *) hostinfo->h_addr;
|
||||
err = bind (sock, (struct sockaddr *) &addr, sizeof (addr));
|
||||
if (err) {
|
||||
|
@ -202,6 +203,18 @@ main (int argc, char *argv[])
|
|||
goto DONE;
|
||||
}
|
||||
|
||||
addrlen = sizeof (addr);
|
||||
err = getsockname (sock, (struct sockaddr *) &addr, &addrlen);
|
||||
if (err) {
|
||||
fprintf (stderr, "Error: getsockname() failed: %s\n",
|
||||
strerror (errno));
|
||||
close (sock);
|
||||
ret = 1;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
printf ("smtp_dummy_port='%d'\n", ntohs (addr.sin_port));
|
||||
|
||||
err = listen (sock, 1);
|
||||
if (err) {
|
||||
fprintf (stderr, "Error: listen() failed: %s\n",
|
||||
|
|
|
@ -326,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\")
|
||||
|
|
Loading…
Reference in a new issue