Testsuite: move test.again.dns and test.fail.dns handling to fakens
authorJeremy Harris <jgh146exb@wizmail.org>
Sat, 23 May 2015 17:07:58 +0000 (18:07 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Sat, 23 May 2015 18:50:13 +0000 (19:50 +0100)
src/src/dns.c
src/src/host.c
test/README
test/src/fakens.c
test/stderr/0069
test/stderr/0183
test/stderr/0605
test/stderr/2202

index 4ca349cd118546cfb6177dc6e2b1967f8811bd3e..d55ff83b135ccc76f21181b42807ab4691807251 100644 (file)
@@ -53,32 +53,6 @@ Ustrncpy(name, domain, len);
 name[len] = 0;
 endname = name + len;
 
 name[len] = 0;
 endname = name + len;
 
-/* This code, for forcing TRY_AGAIN and NO_RECOVERY, is here so that it works
-for the old test suite that uses a real nameserver. When the old test suite is
-eventually abandoned, this code could be moved into the fakens utility. */
-
-if (len >= 14 && Ustrcmp(endname - 14, "test.again.dns") == 0)
-  {
-  int delay = Uatoi(name);  /* digits at the start of the name */
-  DEBUG(D_dns) debug_printf("Return from DNS lookup of %s (%s) faked for testing\n",
-    name, dns_text_type(type));
-  if (delay > 0)
-    {
-    DEBUG(D_dns) debug_printf("delaying %d seconds\n", delay);
-    sleep(delay);
-    }
-  h_errno = TRY_AGAIN;
-  return -1;
-  }
-
-if (len >= 13 && Ustrcmp(endname - 13, "test.fail.dns") == 0)
-  {
-  DEBUG(D_dns) debug_printf("Return from DNS lookup of %s (%s) faked for testing\n",
-    name, dns_text_type(type));
-  h_errno = NO_RECOVERY;
-  return -1;
-  }
-
 /* Look for the fakens utility, and if it exists, call it. */
 
 (void)string_format(utilname, sizeof(utilname), "%s/bin/fakens",
 /* Look for the fakens utility, and if it exists, call it. */
 
 (void)string_format(utilname, sizeof(utilname), "%s/bin/fakens",
index 643900b21b20094863b03c5d3abaf4047b0f4d13..00a23310f0b858922eee7cbde7795f4223a7f37c 100644 (file)
@@ -1928,16 +1928,6 @@ BOOL temp_error = FALSE;
 int af;
 #endif
 
 int af;
 #endif
 
-/* If we are in the test harness, a name ending in .test.again.dns always
-forces a temporary error response, unless the name is in
-dns_again_means_nonexist. */
-
-if (running_in_test_harness)
-  {
-  const uschar *endname = host->name + Ustrlen(host->name);
-  if (Ustrcmp(endname - 14, "test.again.dns") == 0) goto RETURN_AGAIN;
-  }
-
 /* Make sure DNS options are set as required. This appears to be necessary in
 some circumstances when the get..byname() function actually calls the DNS. */
 
 /* Make sure DNS options are set as required. This appears to be necessary in
 some circumstances when the get..byname() function actually calls the DNS. */
 
index f63c97fa4e21499b0e72e0f2face2a8bd2af664f..7bf4ceea550febabfc546bf09cafb13d2c5526d0 100644 (file)
@@ -1144,9 +1144,6 @@ fake zone files.  These are:
                     data block. The addresses that are generated are in the
                     10.250.0.0/16 network.
 
                     data block. The addresses that are generated are in the
                     10.250.0.0/16 network.
 
-The domain names that are handled directly by Exim, without being passed to
-fakens, are:
-
   test.again.dns    This always provokes a TRY_AGAIN response, for testing the
                     handling of temporary DNS error. If the full domain name
                     starts with digits, a delay of that many seconds occurs.
   test.again.dns    This always provokes a TRY_AGAIN response, for testing the
                     handling of temporary DNS error. If the full domain name
                     starts with digits, a delay of that many seconds occurs.
@@ -1154,10 +1151,6 @@ fakens, are:
   test.fail.dns     This always provokes a NO_RECOVERY response, for testing
                     DNS server failures.
 
   test.fail.dns     This always provokes a NO_RECOVERY response, for testing
                     DNS server failures.
 
-This special handling could now be done in the fakens program, but while the
-old test suite is still being used it has to be done in Exim itself, so for the
-moment it remains there.
-
 The use of gethostbyname() and its IPv6 friends is also subverted when Exim is
 running in the test harness. The test code handles a few special names
 directly; for all the others it uses DNS lookups, which are then handled as
 The use of gethostbyname() and its IPv6 friends is also subverted when Exim is
 running in the test harness. The test code handles a few special names
 directly; for all the others it uses DNS lookups, which are then handled as
index bb8d4e206c6592bd163573e1a62070827ff3337b..aff5f40f6fbb1eadf7e62e99fdb4271c5dbd5a59 100644 (file)
@@ -583,6 +583,55 @@ alarmfn(int sig)
 {
 }
 
 {
 }
 
+
+/*************************************************
+*     Special-purpose domains                    *
+*************************************************/
+
+static int
+special_manyhome(uschar * packet, uschar * domain)
+{
+uschar *pk = packet + 12;
+uschar *rdlptr;
+int i, j;
+
+memset(packet, 0, 12);
+
+for (i = 104; i <= 111; i++) for (j = 0; j <= 255; j++)
+  {
+  pk = packname(domain, pk);
+  *pk++ = (ns_t_a >> 8) & 255;
+  *pk++ = (ns_t_a) & 255;
+  *pk++ = 0;
+  *pk++ = 1;     /* class = IN */
+  pk += 4;       /* TTL field; don't care */
+  rdlptr = pk;   /* remember rdlength field */
+  pk += 2;
+
+  *pk++ = 10; *pk++ = 250; *pk++ = i; *pk++ = j;
+
+  rdlptr[0] = ((pk - rdlptr - 2) >> 8) & 255;
+  rdlptr[1] = (pk - rdlptr - 2) & 255;
+  }
+
+packet[6] = (2048 >> 8) & 255;
+packet[7] = 2048 & 255;
+packet[10] = 0;
+packet[11] = 0;
+
+(void)fwrite(packet, 1, pk - packet, stdout);
+return 0;
+}
+
+static int
+special_again(uschar * packet, uschar * domain)
+{
+int delay = atoi(CCS domain);  /* digits at the start of the name */
+if (delay > 0) sleep(delay);
+return TRY_AGAIN;
+}
+
+
 /*************************************************
 *           Entry point and main program         *
 *************************************************/
 /*************************************************
 *           Entry point and main program         *
 *************************************************/
@@ -666,38 +715,11 @@ domain[domlen] = 0;
 for (i = 0; i < domlen; i++) domain[i] = tolower(domain[i]);
 
 if (Ustrcmp(domain, "manyhome.test.ex") == 0 && Ustrcmp(qtype, "A") == 0)
 for (i = 0; i < domlen; i++) domain[i] = tolower(domain[i]);
 
 if (Ustrcmp(domain, "manyhome.test.ex") == 0 && Ustrcmp(qtype, "A") == 0)
-  {
-  uschar *pk = packet + 12;
-  uschar *rdlptr;
-  int i, j;
-
-  memset(packet, 0, 12);
-
-  for (i = 104; i <= 111; i++) for (j = 0; j <= 255; j++)
-    {
-    pk = packname(domain, pk);
-    *pk++ = (ns_t_a >> 8) & 255;
-    *pk++ = (ns_t_a) & 255;
-    *pk++ = 0;
-    *pk++ = 1;     /* class = IN */
-    pk += 4;       /* TTL field; don't care */
-    rdlptr = pk;   /* remember rdlength field */
-    pk += 2;
-
-    *pk++ = 10; *pk++ = 250; *pk++ = i; *pk++ = j;
-
-    rdlptr[0] = ((pk - rdlptr - 2) >> 8) & 255;
-    rdlptr[1] = (pk - rdlptr - 2) & 255;
-    }
-
-  packet[6] = (2048 >> 8) & 255;
-  packet[7] = 2048 & 255;
-  packet[10] = 0;
-  packet[11] = 0;
-
-  (void)fwrite(packet, 1, pk - packet, stdout);
-  return 0;
-  }
+  return special_manyhome(packet, domain);
+else if (domlen >= 14 && Ustrcmp(domain + domlen - 14, "test.again.dns") == 0)
+  return special_again(packet, domain);
+else if (domlen >= 13 && Ustrcmp(domain + domlen - 13, "test.fail.dns") == 0)
+  return NO_RECOVERY;
 
 
 if (Ustrchr(domain, '.') == NULL && qualify != NULL &&
 
 
 if (Ustrchr(domain, '.') == NULL && qualify != NULL &&
index 0af08eaa6603c129e5e68ba9903916f7c314bc60..15b8a4318adfecfd1cc8f04fcd05ca22b4fb0a6c 100644 (file)
@@ -137,6 +137,9 @@ LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown
 >>> processing "deny"
 >>> check hosts = +include_defer : test.again.dns
 >>> test.again.dns in dns_again_means_nonexist? no (option unset)
 >>> processing "deny"
 >>> check hosts = +include_defer : test.again.dns
 >>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> no IP address found for host test.again.dns (during SMTP connection from [V4NET.0.0.13])
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
 LOG: DNS lookup of "test.again.dns" deferred: accepted by +include_defer
 >>> deny: condition test succeeded in ACL "check_recipienta"
 >>> end of ACL "check_recipienta": DENY
 LOG: DNS lookup of "test.again.dns" deferred: accepted by +include_defer
 >>> deny: condition test succeeded in ACL "check_recipienta"
 >>> end of ACL "check_recipienta": DENY
@@ -157,6 +160,9 @@ LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown
 >>> processing "accept"
 >>> check hosts = test.again.dns : V4NET.0.0.13
 >>> test.again.dns in dns_again_means_nonexist? no (option unset)
 >>> processing "accept"
 >>> check hosts = test.again.dns : V4NET.0.0.13
 >>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> no IP address found for host test.again.dns (during SMTP connection from [V4NET.0.0.13])
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
 >>> host in "test.again.dns : V4NET.0.0.13"? list match deferred for test.again.dns
 >>> accept: condition test deferred in ACL "check_recipientb"
 LOG: H=[V4NET.0.0.13] F=<userx@test.ex> temporarily rejected RCPT <b@test.ex>: DNS lookup of "test.again.dns" deferred
 >>> host in "test.again.dns : V4NET.0.0.13"? list match deferred for test.again.dns
 >>> accept: condition test deferred in ACL "check_recipientb"
 LOG: H=[V4NET.0.0.13] F=<userx@test.ex> temporarily rejected RCPT <b@test.ex>: DNS lookup of "test.again.dns" deferred
@@ -176,6 +182,9 @@ LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown
 >>> processing "accept"
 >>> check hosts = +ignore_defer : test.again.dns : V4NET.0.0.13
 >>> test.again.dns in dns_again_means_nonexist? no (option unset)
 >>> processing "accept"
 >>> check hosts = +ignore_defer : test.again.dns : V4NET.0.0.13
 >>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> no IP address found for host test.again.dns (during SMTP connection from [V4NET.0.0.13])
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
 >>> DNS lookup of "test.again.dns" deferred: item ignored by +ignore_defer
 >>> host in "+ignore_defer : test.again.dns : V4NET.0.0.13"? yes (matched "V4NET.0.0.13")
 >>> accept: condition test succeeded in ACL "check_recipientc"
 >>> DNS lookup of "test.again.dns" deferred: item ignored by +ignore_defer
 >>> host in "+ignore_defer : test.again.dns : V4NET.0.0.13"? yes (matched "V4NET.0.0.13")
 >>> accept: condition test succeeded in ACL "check_recipientc"
index b5e5deb46b32c60756595868465e00d3fd6c4995..70385352e443715a655d4b1272c6ae1c12f46045 100644 (file)
@@ -30,7 +30,7 @@ local_part=userx domain=test.again.dns
 calling lookuphost router
 lookuphost router called for userx@test.again.dns
   domain = test.again.dns
 calling lookuphost router
 lookuphost router called for userx@test.again.dns
   domain = test.again.dns
-Return from DNS lookup of test.again.dns (MX) faked for testing
+DNS lookup of test.again.dns (MX) using fakens
 DNS lookup of test.again.dns (MX) gave TRY_AGAIN
 test.again.dns in dns_again_means_nonexist? no (option unset)
 returning DNS_AGAIN
 DNS lookup of test.again.dns (MX) gave TRY_AGAIN
 test.again.dns in dns_again_means_nonexist? no (option unset)
 returning DNS_AGAIN
@@ -122,7 +122,7 @@ expanded list of hosts = "test.again.dns" options = bydns
 set transport smtp
 finding IP address for test.again.dns
 doing DNS lookup
 set transport smtp
 finding IP address for test.again.dns
 doing DNS lookup
-Return from DNS lookup of test.again.dns (A) faked for testing
+DNS lookup of test.again.dns (A) using fakens
 DNS lookup of test.again.dns (A) gave TRY_AGAIN
 test.again.dns in dns_again_means_nonexist? no (option unset)
 returning DNS_AGAIN
 DNS lookup of test.again.dns (A) gave TRY_AGAIN
 test.again.dns in dns_again_means_nonexist? no (option unset)
 returning DNS_AGAIN
@@ -223,7 +223,7 @@ local_part=userx domain=test.fail.dns
 calling lookuphost router
 lookuphost router called for userx@test.fail.dns
   domain = test.fail.dns
 calling lookuphost router
 lookuphost router called for userx@test.fail.dns
   domain = test.fail.dns
-Return from DNS lookup of test.fail.dns (MX) faked for testing
+DNS lookup of test.fail.dns (MX) using fakens
 DNS lookup of test.fail.dns (MX) gave NO_RECOVERY
 returning DNS_FAIL
 lookuphost router: defer for userx@test.fail.dns
 DNS lookup of test.fail.dns (MX) gave NO_RECOVERY
 returning DNS_FAIL
 lookuphost router: defer for userx@test.fail.dns
@@ -314,7 +314,7 @@ expanded list of hosts = "test.fail.dns" options = bydns
 set transport smtp
 finding IP address for test.fail.dns
 doing DNS lookup
 set transport smtp
 finding IP address for test.fail.dns
 doing DNS lookup
-Return from DNS lookup of test.fail.dns (A) faked for testing
+DNS lookup of test.fail.dns (A) using fakens
 DNS lookup of test.fail.dns (A) gave NO_RECOVERY
 returning DNS_FAIL
 useryz router: defer for usery@test.fail.dns
 DNS lookup of test.fail.dns (A) gave NO_RECOVERY
 returning DNS_FAIL
 useryz router: defer for usery@test.fail.dns
@@ -599,7 +599,7 @@ srv in "^srv"? yes (matched "^srv")
 calling srv router
 srv router called for srv@test.again.dns
   domain = test.again.dns
 calling srv router
 srv router called for srv@test.again.dns
   domain = test.again.dns
-Return from DNS lookup of _smtp._tcp.test.again.dns (SRV) faked for testing
+DNS lookup of _smtp._tcp.test.again.dns (SRV) using fakens
 DNS lookup of _smtp._tcp.test.again.dns (SRV) gave TRY_AGAIN
 _smtp._tcp.test.again.dns in dns_again_means_nonexist? no (option unset)
 returning DNS_AGAIN
 DNS lookup of _smtp._tcp.test.again.dns (SRV) gave TRY_AGAIN
 _smtp._tcp.test.again.dns in dns_again_means_nonexist? no (option unset)
 returning DNS_AGAIN
@@ -619,17 +619,17 @@ srv in "^srv"? yes (matched "^srv")
 calling srv router
 srv router called for srv@test.fail.dns
   domain = test.fail.dns
 calling srv router
 srv router called for srv@test.fail.dns
   domain = test.fail.dns
-Return from DNS lookup of _smtp._tcp.test.fail.dns (SRV) faked for testing
+DNS lookup of _smtp._tcp.test.fail.dns (SRV) using fakens
 DNS lookup of _smtp._tcp.test.fail.dns (SRV) gave NO_RECOVERY
 returning DNS_FAIL
 test.fail.dns in "test.fail.dns"? yes (matched "test.fail.dns")
 DNS_FAIL treated as DNS_NODATA (domain in srv_fail_domains)
 DNS lookup of _smtp._tcp.test.fail.dns (SRV) gave NO_RECOVERY
 returning DNS_FAIL
 test.fail.dns in "test.fail.dns"? yes (matched "test.fail.dns")
 DNS_FAIL treated as DNS_NODATA (domain in srv_fail_domains)
-Return from DNS lookup of test.fail.dns (MX) faked for testing
+DNS lookup of test.fail.dns (MX) using fakens
 DNS lookup of test.fail.dns (MX) gave NO_RECOVERY
 returning DNS_FAIL
 test.fail.dns in "test.fail.dns"? yes (matched "test.fail.dns")
 DNS_FAIL treated as DNS_NODATA (domain in mx_fail_domains)
 DNS lookup of test.fail.dns (MX) gave NO_RECOVERY
 returning DNS_FAIL
 test.fail.dns in "test.fail.dns"? yes (matched "test.fail.dns")
 DNS_FAIL treated as DNS_NODATA (domain in mx_fail_domains)
-Return from DNS lookup of test.fail.dns (A) faked for testing
+DNS lookup of test.fail.dns (A) using fakens
 DNS lookup of test.fail.dns (A) gave NO_RECOVERY
 returning DNS_FAIL
 srv router: defer for srv@test.fail.dns
 DNS lookup of test.fail.dns (A) gave NO_RECOVERY
 returning DNS_FAIL
 srv router: defer for srv@test.fail.dns
index 9e144d402d028d244ad618bf70938c551137b434..d2def942f3e042c9b1b2df1e42f6465e778085f9 100644 (file)
@@ -10,6 +10,9 @@
 >>> processing "accept"
 >>> check hosts = test.again.dns
 >>> test.again.dns in dns_again_means_nonexist? no (option unset)
 >>> processing "accept"
 >>> check hosts = test.again.dns
 >>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> no IP address found for host test.again.dns (during SMTP connection from (test) [ip4.ip4.ip4.ip4])
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
 >>> host in "test.again.dns"? list match deferred for test.again.dns
 >>> accept: condition test deferred in inline ACL
 LOG: H=(test) [ip4.ip4.ip4.ip4] F=<ralph@dustyshoes.tld> temporarily rejected RCPT <bob@anotherone.tld>: DNS lookup of "test.again.dns" deferred
 >>> host in "test.again.dns"? list match deferred for test.again.dns
 >>> accept: condition test deferred in inline ACL
 LOG: H=(test) [ip4.ip4.ip4.ip4] F=<ralph@dustyshoes.tld> temporarily rejected RCPT <bob@anotherone.tld>: DNS lookup of "test.again.dns" deferred
index 043e9956901284f265849468696d49c191466167..24ebf9947460260f461634616433b9c5dde58ee6 100644 (file)
@@ -36,7 +36,7 @@ internal_search_find: file="NULL"
   type=dnsdb key=">:defer_never,mxh=cioce.test.again.dns"
 database lookup required for >:defer_never,mxh=cioce.test.again.dns
 dnsdb key: cioce.test.again.dns
   type=dnsdb key=">:defer_never,mxh=cioce.test.again.dns"
 database lookup required for >:defer_never,mxh=cioce.test.again.dns
 dnsdb key: cioce.test.again.dns
-Return from DNS lookup of cioce.test.again.dns (MX) faked for testing
+DNS lookup of cioce.test.again.dns (MX) using fakens
 DNS lookup of cioce.test.again.dns (MX) gave TRY_AGAIN
 cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*")
 cioce.test.again.dns is in dns_again_means_nonexist: returning DNS_NOMATCH
 DNS lookup of cioce.test.again.dns (MX) gave TRY_AGAIN
 cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*")
 cioce.test.again.dns is in dns_again_means_nonexist: returning DNS_NOMATCH
@@ -55,8 +55,15 @@ Forward DNS security status: unverified
   ip4.ip4.ip4.ip4 OK
 sender_fullhost = the.local.host.name [ip4.ip4.ip4.ip4]
 sender_rcvhost = the.local.host.name ([ip4.ip4.ip4.ip4])
   ip4.ip4.ip4.ip4 OK
 sender_fullhost = the.local.host.name [ip4.ip4.ip4.ip4]
 sender_rcvhost = the.local.host.name ([ip4.ip4.ip4.ip4])
+using host_fake_gethostbyname for cioce.test.again.dns (IPv4)
+DNS lookup of cioce.test.again.dns (A) using fakens
+DNS lookup of cioce.test.again.dns (A) gave TRY_AGAIN
 cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*")
 cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*")
-cioce.test.again.dns is in dns_again_means_nonexist: returning HOST_FIND_FAILED
+cioce.test.again.dns is in dns_again_means_nonexist: returning DNS_NOMATCH
+get[host|ipnode]byname[2](af=inet) returned 1 (HOST_NOT_FOUND)
+no IP address found for host cioce.test.again.dns (during SMTP connection from the.local.host.name [ip4.ip4.ip4.ip4])
+LOG: host_lookup_failed MAIN
+  no IP address found for host cioce.test.again.dns (during SMTP connection from the.local.host.name [ip4.ip4.ip4.ip4])
 failed to find IP address for cioce.test.again.dns: item ignored by +ignore_unknown
 host in "+ignore_unknown : *.cioce.test.again.dns : cioce.test.again.dns : "? no (end of list)
 accept: condition test failed in ACL "rcpt"
 failed to find IP address for cioce.test.again.dns: item ignored by +ignore_unknown
 host in "+ignore_unknown : *.cioce.test.again.dns : cioce.test.again.dns : "? no (end of list)
 accept: condition test failed in ACL "rcpt"