summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorPaul Groke <paul.groke@dynatrace.com>2020-12-10 17:38:14 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-12-29 17:49:36 +0100
commit8324dc8b1a730445e7aa91f62d7f88b8376e4aee (patch)
treef4ef26e256e8887a5cc6adb34a3c504dcd5d449d /tests/unit
parent68dde8e330a2580c1af3f34cc1971716948c307b (diff)
downloadcurl-8324dc8b1a730445e7aa91f62d7f88b8376e4aee.tar.gz
dns: extend CURLOPT_RESOLVE syntax for adding non-permanent entries
Extend the syntax of CURLOPT_RESOLVE strings: allow using a '+' prefix (similar to the existing '-' prefix for removing entries) to add DNS cache entries that will time out just like entries that are added by libcurl itself. Append " (non-permanent)" to info log message in case a non-permanent entry is added. Adjust relevant comments to reflect the new behavior. Adjust documentation. Extend unit1607 to test the new functionality. Closes #6294
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/unit1607.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/tests/unit/unit1607.c b/tests/unit/unit1607.c
index f1016837b..5be42dbeb 100644
--- a/tests/unit/unit1607.c
+++ b/tests/unit/unit1607.c
@@ -49,6 +49,9 @@ struct testcase {
const char *host;
int port;
+ /* whether we expect a permanent or non-permanent cache entry */
+ bool permanent;
+
/* 0 to 9 addresses expected from hostcache */
const char *address[10];
};
@@ -67,34 +70,37 @@ static const char skip = 0;
static const struct testcase tests[] = {
/* spaces aren't allowed, for now */
{ "test.com:80:127.0.0.1, 127.0.0.2",
- "test.com", 80, { NULL, }
+ "test.com", 80, TRUE, { NULL, }
},
{ "TEST.com:80:,,127.0.0.1,,,127.0.0.2,,,,::1,,,",
- "test.com", 80, { "127.0.0.1", "127.0.0.2", IPV6ONLY("::1"), }
+ "test.com", 80, TRUE, { "127.0.0.1", "127.0.0.2", IPV6ONLY("::1"), }
},
{ "test.com:80:::1,127.0.0.1",
- "test.com", 80, { IPV6ONLY("::1"), "127.0.0.1", }
+ "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
},
{ "test.com:80:[::1],127.0.0.1",
- "test.com", 80, { IPV6ONLY("::1"), "127.0.0.1", }
+ "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
},
{ "test.com:80:::1",
- "test.com", 80, { IPV6ONLY("::1"), }
+ "test.com", 80, TRUE, { IPV6ONLY("::1"), }
},
{ "test.com:80:[::1]",
- "test.com", 80, { IPV6ONLY("::1"), }
+ "test.com", 80, TRUE, { IPV6ONLY("::1"), }
},
{ "test.com:80:127.0.0.1",
- "test.com", 80, { "127.0.0.1", }
+ "test.com", 80, TRUE, { "127.0.0.1", }
},
{ "test.com:80:,127.0.0.1",
- "test.com", 80, { "127.0.0.1", }
+ "test.com", 80, TRUE, { "127.0.0.1", }
},
{ "test.com:80:127.0.0.1,",
- "test.com", 80, { "127.0.0.1", }
+ "test.com", 80, TRUE, { "127.0.0.1", }
},
{ "test.com:0:127.0.0.1",
- "test.com", 0, { "127.0.0.1", }
+ "test.com", 0, TRUE, { "127.0.0.1", }
+ },
+ { "+test.com:80:127.0.0.1,",
+ "test.com", 80, FALSE, { "127.0.0.1", }
},
};
@@ -188,10 +194,18 @@ UNITTEST_START
break;
}
- if(dns->timestamp != 0) {
- fprintf(stderr, "%s:%d tests[%d] failed. the timestamp is not zero. "
- "for tests[%d].address[%d\n",
- __FILE__, __LINE__, i, i, j);
+ if(dns->timestamp != 0 && tests[i].permanent) {
+ fprintf(stderr, "%s:%d tests[%d] failed. the timestamp is not zero "
+ "but tests[%d].permanent is TRUE\n",
+ __FILE__, __LINE__, i, i);
+ problem = true;
+ break;
+ }
+
+ if(dns->timestamp == 0 && !tests[i].permanent) {
+ fprintf(stderr, "%s:%d tests[%d] failed. the timestamp is zero "
+ "but tests[%d].permanent is FALSE\n",
+ __FILE__, __LINE__, i, i);
problem = true;
break;
}