]> granicus.if.org Git - libevent/commitdiff
test: skip dns_initialize_nameservers if missing /etc/resolv.conf
authorPierce Lopez <pierce.lopez@gmail.com>
Tue, 14 Sep 2021 05:19:36 +0000 (01:19 -0400)
committerPierce Lopez <pierce.lopez@gmail.com>
Tue, 14 Sep 2021 05:19:36 +0000 (01:19 -0400)
some build systems run tests in minimal containers with no resolv.conf,
and the primary thing this test does is load the default /etc/resolv.conf

test/regress_dns.c

index 3d97cb229ac2419fe0768dd474ee09c0d2704750..f97db676f8380e629189aea9614086e185f52a82 100644 (file)
@@ -1146,6 +1146,15 @@ dns_initialize_nameservers_test(void *arg)
        struct sockaddr_storage ss;
        int size;
 
+#ifndef _WIN32
+       /* /etc/resolv.conf does not exist in some test container
+        * setups but EVDNS_BASE_INITIALIZE_NAMESERVERS requires it */
+       struct stat st;
+       if (stat("/etc/resolv.conf", &st) < 0 || st.st_size == 0) {
+               tt_skip();
+       }
+#endif
+
        dns = evdns_base_new(base, 0);
        tt_assert(dns);
        tt_int_op(evdns_base_get_nameserver_addr(dns, 0, NULL, 0), ==, -1);