summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2015-05-23 18:07:58 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2015-05-23 19:50:13 +0100
commitdd2a32ad5058ad7831621b99a1eadc264d4982c9 (patch)
tree33595a8c88500cd7df2c62c3025ca3dff045b3fb /test/src
parent0539a19dc27efcfc77713a87aba6b61fef947249 (diff)
Testsuite: move test.again.dns and test.fail.dns handling to fakens
Diffstat (limited to 'test/src')
-rw-r--r--test/src/fakens.c86
1 files changed, 54 insertions, 32 deletions
diff --git a/test/src/fakens.c b/test/src/fakens.c
index bb8d4e206..aff5f40f6 100644
--- a/test/src/fakens.c
+++ b/test/src/fakens.c
@@ -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 *
*************************************************/
@@ -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)
- {
- 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 &&