summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2006-02-16 10:05:33 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2006-02-16 10:05:33 +0000
commit75e0e026a196fa852a855d5148f29be29ac2d92f (patch)
treecbf860a3c39a64dbce2b274a00262cc6baae2f47 /src
parent230205fc0acfc71dff9ce42fb20d2caba82fbd36 (diff)
Code tidies to remove stuff that was needed only for the old test suite.
Also, use -odi for bounces when in the test harness, unless queue_only is set.
Diffstat (limited to 'src')
-rw-r--r--src/src/child.c40
-rw-r--r--src/src/dns.c14
-rw-r--r--src/src/exim.c8
-rw-r--r--src/src/host.c120
-rw-r--r--src/src/ip.c12
5 files changed, 40 insertions, 154 deletions
diff --git a/src/src/child.c b/src/src/child.c
index e67f76666..05e71bc3f 100644
--- a/src/src/child.c
+++ b/src/src/child.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/child.c,v 1.9 2006/02/14 10:26:27 ph10 Exp $ */
+/* $Cambridge: exim/src/src/child.c,v 1.10 2006/02/16 10:05:33 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -219,21 +219,39 @@ pid = fork();
/* Child process: make the reading end of the pipe into the standard input and
close the writing end. If debugging, pass debug_fd as stderr. Then re-exec
-Exim. Failure is signalled with EX_EXECFAILED, but this shouldn't occur! */
+Exim with appropriat options. In the test harness, use -odi unless queue_only
+is set, so that the bounce is fully delivered before returning. Failure is
+signalled with EX_EXECFAILED (specified by CEE_EXEC_EXIT), but this shouldn't
+occur. */
if (pid == 0)
{
force_fd(pfd[pipe_read], 0);
(void)close(pfd[pipe_write]);
if (debug_fd > 0) force_fd(debug_fd, 2);
- if (sender_authentication != NULL)
- child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 8,
- US"-t", US"-oem", US"-oi", US"-f", sender, US"-oMas",
- sender_authentication, message_id_option);
- else
- child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 6,
- US"-t", US"-oem", US"-oi", US"-f", sender, message_id_option);
- /* Control does not return here. */
+ if (running_in_test_harness && !queue_only)
+ {
+ if (sender_authentication != NULL)
+ child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 9,
+ US "-odi", US"-t", US"-oem", US"-oi", US"-f", sender, US"-oMas",
+ sender_authentication, message_id_option);
+ else
+ child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 7,
+ US "-odi", US"-t", US"-oem", US"-oi", US"-f", sender,
+ message_id_option);
+ /* Control does not return here. */
+ }
+ else /* Not test harness */
+ {
+ if (sender_authentication != NULL)
+ child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 8,
+ US"-t", US"-oem", US"-oi", US"-f", sender, US"-oMas",
+ sender_authentication, message_id_option);
+ else
+ child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 6,
+ US"-t", US"-oem", US"-oi", US"-f", sender, message_id_option);
+ /* Control does not return here. */
+ }
}
/* Parent process. Save fork() errno and close the reading end of the stdin
@@ -256,7 +274,7 @@ if (pid > 0)
errno = save_errno;
return (pid_t)(-1);
}
-#endif
+#endif /* STAND_ALONE */
diff --git a/src/src/dns.c b/src/src/dns.c
index 56d3f3471..1a940b6ab 100644
--- a/src/src/dns.c
+++ b/src/src/dns.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/dns.c,v 1.13 2006/02/07 11:19:00 ph10 Exp $ */
+/* $Cambridge: exim/src/src/dns.c,v 1.14 2006/02/16 10:05:33 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -692,15 +692,9 @@ for (i = 0; i < 10; i++)
}
else if (type_rr.data != NULL)
{
- if (running_in_test_harness &&
- Ustrcmp(type_rr.name, "uppercase.test.ex") == 0)
- *fully_qualified_name = US"UpperCase.test.ex";
- else
- {
- if (Ustrcmp(type_rr.name, *fully_qualified_name) != 0 &&
- type_rr.name[0] != '*')
- *fully_qualified_name = string_copy_dnsdomain(type_rr.name);
- }
+ if (Ustrcmp(type_rr.name, *fully_qualified_name) != 0 &&
+ type_rr.name[0] != '*')
+ *fully_qualified_name = string_copy_dnsdomain(type_rr.name);
}
}
diff --git a/src/src/exim.c b/src/src/exim.c
index 5b0eb0335..ef1865541 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/exim.c,v 1.32 2006/02/10 16:29:20 ph10 Exp $ */
+/* $Cambridge: exim/src/src/exim.c,v 1.33 2006/02/16 10:05:33 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -4740,12 +4740,6 @@ while (more)
close_unwanted(); /* Close unwanted file descriptors and TLS */
exim_nullstd(); /* Ensure std{in,out,err} exist */
- /* Occasionally in the test harness we don't have synchronous delivery
- set (can happen with bounces). In that case, let the old process finish
- before continuing, to keep the debug output the same. */
-
- if (running_in_test_harness && !synchronous_delivery) millisleep(100);
-
/* Re-exec Exim if we need to regain privilege (note: in mua_wrapper
mode, deliver_drop_privilege is forced TRUE). */
diff --git a/src/src/host.c b/src/src/host.c
index 87cd7c494..07d28395e 100644
--- a/src/src/host.c
+++ b/src/src/host.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/host.c,v 1.21 2006/02/07 16:36:25 ph10 Exp $ */
+/* $Cambridge: exim/src/src/host.c,v 1.22 2006/02/16 10:05:33 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -94,55 +94,6 @@ return (unsigned int)(random_seed >> 16) % limit;
/*************************************************
-* Sort addresses when testing *
-*************************************************/
-
-/* This function is called only when running in the test harness. It sorts a
-number of multihomed host IP addresses into the order, so as to get
-repeatability. This doesn't have to be efficient. But don't interchange IPv4
-and IPv6 addresses!
-
-NOTE:
-This sorting is not necessary for the new test harness, because it
-doesn't call the real DNS resolver, and its output is repeatable. However,
-until the old test harness is discarded, we need to retain this capability.
-The new harness is being developed towards the end of 2005. It will be some
-time before it can do everything that the old one can do.
-
-Arguments:
- host -> the first host item
- last -> the last host item
-
-Returns: nothing
-*/
-
-static void
-sort_addresses(host_item *host, host_item *last)
-{
-BOOL done = FALSE;
-while (!done)
- {
- host_item *h;
- done = TRUE;
- for (h = host; h != last; h = h->next)
- {
- if ((Ustrchr(h->address, ':') == NULL) !=
- (Ustrchr(h->next->address, ':') == NULL))
- continue;
- if (Ustrcmp(h->address, h->next->address) > 0)
- {
- uschar *temp = h->address;
- h->address = h->next->address;
- h->next->address = temp;
- done = FALSE;
- }
- }
- }
-}
-
-
-
-/*************************************************
* Replace gethostbyname() when testing *
*************************************************/
@@ -151,9 +102,8 @@ getipnodebyname() when running in the test harness. It recognizes the name
"manyhome.test.ex" and generates a humungous number of IP addresses. It also
recognizes an unqualified "localhost" and forces it to the appropriate loopback
address. IP addresses are treated as literals. For other names, it uses the DNS
-to find the host name. In the new test harness, this means it will access only
-the fake DNS resolver. In the old harness it will call the real resolver and
-access the test zone.
+to find the host name. In the test harness, this means it will access only the
+fake DNS resolver.
Arguments:
name the host name or a textual IP address
@@ -1781,27 +1731,6 @@ if (sender_host_name == NULL)
return FAIL;
}
-/* We have a host name. If we are running in the test harness, we want the host
-name and its alias to appear always the same way round. There are only ever two
-names in these tests. If one of them contains "alias", make sure it is second;
-otherwise put them in alphabetical order. */
-
-if (running_in_test_harness && *sender_host_aliases != NULL &&
- (
- Ustrstr(sender_host_name, "alias") != NULL ||
- (
- Ustrstr(*sender_host_aliases, "alias") == NULL &&
- Ustrcmp(sender_host_name, *sender_host_aliases) > 0
- )
- ))
- {
- uschar *temp = sender_host_name;
- sender_host_name = *sender_host_aliases;
- *sender_host_aliases = temp;
- }
-
-/* Debug output what was found, after test harness swapping, for consistency */
-
HDEBUG(D_host_lookup)
{
uschar **aliases = sender_host_aliases;
@@ -2155,11 +2084,6 @@ host_remove_duplicates(host, &last);
yield = local_host_check?
host_scan_for_local_hosts(host, &last, NULL) : HOST_FOUND;
-/* When running in the test harness, sort into the order of addresses so as to
-get repeatability. */
-
-if (running_in_test_harness) sort_addresses(host, last);
-
HDEBUG(D_host_lookup)
{
host_item *h;
@@ -2584,11 +2508,6 @@ if (rc != DNS_SUCCEED)
else
if (rc == HOST_IGNORED) rc = HOST_FIND_FAILED; /* No special action */
- /* When running in the test harness, sort into the order of addresses so as
- to get repeatability. */
-
- if (running_in_test_harness) sort_addresses(host, last);
-
DEBUG(D_host_lookup)
{
host_item *h;
@@ -2976,39 +2895,6 @@ if (h != last)
}
#endif
-/* When running in the test harness, we want the hosts always to be in the same
-order so that the debugging output is the same and can be compared. Having a
-fixed set of "random" numbers doesn't actually achieve this, because the RRs
-come back from the resolver in a random order, so the non-random random numbers
-get used in a different order. We therefore have to sort the hosts that have
-the same MX values. We chose do to this by their name and then by IP address.
-The fact that the sort is slow matters not - this is testing only! */
-
-if (running_in_test_harness)
- {
- BOOL done;
- do
- {
- done = TRUE;
- for (h = host; h != last; h = h->next)
- {
- int c = Ustrcmp(h->name, h->next->name);
- if (c == 0) c = Ustrcmp(h->address, h->next->address);
- if (h->mx == h->next->mx && c > 0)
- {
- host_item *next = h->next;
- host_item temp = *h;
- temp.next = next->next;
- *h = *next;
- h->next = next;
- *next = temp;
- done = FALSE;
- }
- }
- }
- while (!done);
- }
-
/* Remove any duplicate IP addresses and then scan the list of hosts for any
whose IP addresses are on the local host. If any are found, all hosts with the
same or higher MX values are removed. However, if the local host has the lowest
diff --git a/src/src/ip.c b/src/src/ip.c
index 062a600b6..0e4eab650 100644
--- a/src/src/ip.c
+++ b/src/src/ip.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/ip.c,v 1.4 2006/02/07 11:19:00 ph10 Exp $ */
+/* $Cambridge: exim/src/src/ip.c,v 1.5 2006/02/16 10:05:33 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -224,17 +224,11 @@ alarm(0);
/* There is a testing facility for simulating a connection timeout, as I
can't think of any other way of doing this. It converts a connection refused
-into a timeout.
-
-I had to add a second fudge to keep the tests working. Attempts to connect to
-10.x.x.x are expected to timeout, but sometimes they now give "No route to
-host". */
+into a timeout if the timeout is set to 999999. */
if (running_in_test_harness)
{
- if ((save_errno == ECONNREFUSED && timeout == 999999) ||
- (save_errno == EHOSTUNREACH && timeout > 0 &&
- Ustrncmp(address, "10.", 3) == 0))
+ if (save_errno == ECONNREFUSED && timeout == 999999)
{
rc = -1;
save_errno = EINTR;