]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: tests for dns_resource_record_equal(); DNAME records
authorJames Coglan <james@neighbourhood.ie>
Wed, 12 Jun 2024 15:36:33 +0000 (16:36 +0100)
committerLuca Boccassi <bluca@debian.org>
Tue, 23 Jul 2024 11:44:35 +0000 (12:44 +0100)
src/resolve/test-dns-rr.c

index 774953218527dd8107815271bd2c1f65fc106485..046ef18f0a7987e94308e7f66846aa2dc493ea48 100644 (file)
@@ -1003,6 +1003,36 @@ TEST(dns_resource_record_equal_cname_fail) {
         ASSERT_FALSE(dns_resource_record_equal(a, b));
 }
 
+/* ================================================================
+ * dns_resource_record_equal() : DNAME
+ * ================================================================ */
+
+TEST(dns_resource_record_equal_dname) {
+        _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *a = NULL, *b = NULL;
+
+        a = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_DNAME, "www.example.com");
+        ASSERT_NOT_NULL(a);
+        a->dname.name = strdup("example.com");
+
+        b = dns_resource_record_copy(a);
+        ASSERT_NOT_NULL(b);
+        ASSERT_TRUE(dns_resource_record_equal(a, b));
+}
+
+TEST(dns_resource_record_equal_dname_fail) {
+        _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *a = NULL, *b = NULL;
+
+        a = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_DNAME, "www.example.com");
+        ASSERT_NOT_NULL(a);
+        a->dname.name = strdup("example.com");
+
+        b = dns_resource_record_copy(a);
+        ASSERT_NOT_NULL(b);
+        free(b->dname.name);
+        b->dname.name = strdup("example.orb");
+        ASSERT_FALSE(dns_resource_record_equal(a, b));
+}
+
 /* ================================================================
  * dns_resource_record_equal() : SOA
  * ================================================================ */