]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: tests for dns_synthesize_family() and dns_synthesize_protocol()
authorJames Coglan <james@neighbourhood.ie>
Mon, 24 Jun 2024 13:43:18 +0000 (14:43 +0100)
committerLuca Boccassi <bluca@debian.org>
Tue, 23 Jul 2024 14:44:07 +0000 (15:44 +0100)
src/resolve/test-dns-synthesize.c

index 5b89e962d24b0f41b24a6fea2588cb355a422e52..64523f4854086dda2d585d529f843015840b64f6 100644 (file)
@@ -8,6 +8,26 @@
 #include "resolved-manager.h"
 #include "tests.h"
 
+/* ================================================================
+ * dns_synthesize_family(), dns_synthesize_protocol()
+ * ================================================================ */
+
+TEST(dns_synthesize_family_and_protocol) {
+        int flags;
+
+        flags = SD_RESOLVED_FLAGS_MAKE(DNS_PROTOCOL_DNS, AF_INET, false, false);
+        ASSERT_EQ(dns_synthesize_family(flags), AF_UNSPEC);
+        ASSERT_EQ(dns_synthesize_protocol(flags), DNS_PROTOCOL_DNS);
+
+        flags = SD_RESOLVED_FLAGS_MAKE(DNS_PROTOCOL_LLMNR, AF_INET6, false, false);
+        ASSERT_EQ(dns_synthesize_family(flags), AF_INET6);
+        ASSERT_EQ(dns_synthesize_protocol(flags), DNS_PROTOCOL_LLMNR);
+
+        flags = SD_RESOLVED_FLAGS_MAKE(DNS_PROTOCOL_MDNS, AF_INET, false, false);
+        ASSERT_EQ(dns_synthesize_family(flags), AF_INET);
+        ASSERT_EQ(dns_synthesize_protocol(flags), DNS_PROTOCOL_MDNS);
+}
+
 /* ================================================================
  * dns_synthesize_answer()
  * ================================================================ */