diff options
author | James Coglan <james@neighbourhood.ie> | 2024-05-21 15:39:26 +0200 |
---|---|---|
committer | James Coglan <james@neighbourhood.ie> | 2024-07-23 15:08:31 +0200 |
commit | 4f4c06f02d4d2e6b645bb88ffc1e031aa45812d3 (patch) | |
tree | 1bcaf4a1b2e4aabd808f7e2799ee88ef8947b5bf /src/resolve/test-dns-cache.c | |
parent | resolved: tests for dns_cache_put() with different RCODEs (diff) | |
download | systemd-4f4c06f02d4d2e6b645bb88ffc1e031aa45812d3.tar.xz systemd-4f4c06f02d4d2e6b645bb88ffc1e031aa45812d3.zip |
resolved: test for dns_cache_put() with empty answer
Diffstat (limited to 'src/resolve/test-dns-cache.c')
-rw-r--r-- | src/resolve/test-dns-cache.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/resolve/test-dns-cache.c b/src/resolve/test-dns-cache.c index c9f084d3de..d708afef7b 100644 --- a/src/resolve/test-dns-cache.c +++ b/src/resolve/test-dns-cache.c @@ -104,6 +104,20 @@ TEST(dns_a_success_is_cached) { ASSERT_FALSE(dns_cache_is_empty(&cache)); } +TEST(dns_a_success_empty_answer_is_not_cached) { + _cleanup_(dns_cache_unrefp) DnsCache cache = new_cache(); + _cleanup_(put_args_unrefp) PutArgs put_args = mk_put_args(); + + put_args.key = dns_resource_key_new(DNS_CLASS_IN, DNS_TYPE_A, "www.example.com"); + ASSERT_NOT_NULL(put_args.key); + put_args.rcode = DNS_RCODE_SUCCESS; + put_args.answer = dns_answer_new(0); + ASSERT_NOT_NULL(put_args.answer); + + ASSERT_OK(cache_put(&cache, &put_args)); + ASSERT_TRUE(dns_cache_is_empty(&cache)); +} + TEST(dns_a_nxdomain_is_cached) { _cleanup_(dns_cache_unrefp) DnsCache cache = new_cache(); _cleanup_(put_args_unrefp) PutArgs put_args = mk_put_args(); |