summary refs log tree commit diff
path: root/resolv
diff options
context:
space:
mode:
authorStefan Liebler <stli@linux.ibm.com>2020-11-23 10:51:24 +0100
committerStefan Liebler <stli@linux.ibm.com>2020-11-23 10:51:24 +0100
commit29fddfc7dfd6444fa61a256e9a0d0127545e1f2e (patch)
tree01bb8ec6b2e22ae9397698b98a378129ab137cf2 /resolv
parent76ea70c613cee23a1846b9605e6433c1fa8baea7 (diff)
downloadglibc-29fddfc7dfd6444fa61a256e9a0d0127545e1f2e.tar.gz
glibc-29fddfc7dfd6444fa61a256e9a0d0127545e1f2e.tar.xz
glibc-29fddfc7dfd6444fa61a256e9a0d0127545e1f2e.zip
Use libnss_files.so for tests posix/bug-ga2 and resolv/tst-leaks2 [BZ #26821]
The tests posix/bug-ga2-mem and resolv/mtrace-tst-leaks2 are failing on
fedora 33 as mtrace reports memory leaks.

The /etc/nsswitch.conf differs between
Fedora 32: hosts:      files dns myhostname
Fedora 33: hosts:      files resolve [!UNAVAIL=return] myhostname dns

Therefore /lib64/libnss_resolve.so.2 (from systemd) and the dependencies
libgcc_s.so.1 and libpthread.so.0 are loaded.

Usually all malloc'ed resources from getaddrinfo / gethostbyname are freed
and the libraries are dlclose'd in nss/nsswitch.c:libc_freeres_fn (free_mem).
Unfortunately, /lib64/libnss_resolve.so.2 is marked with DF_1_NODELETE.
As this library is not unmapped, you'll see "Memory not freed".

Therefore those tests are now only relying on libnss_files.so by making
them test-container tests and providing the required configuration files.

By moving the tests to tests-container, those are now running with
"make check".  Therefore the mtrace part of the tests are also moved
from "make xcheck" to "make check".

bug-ga2.c is now using test-driver.c in order to support WAIT_FOR_DEBUGGER
environment variable.
Diffstat (limited to 'resolv')
-rw-r--r--resolv/Makefile7
-rw-r--r--resolv/tst-leaks2.c6
-rw-r--r--resolv/tst-leaks2.root/etc/hosts1
-rw-r--r--resolv/tst-leaks2.root/etc/nsswitch.conf1
4 files changed, 9 insertions, 6 deletions
diff --git a/resolv/Makefile b/resolv/Makefile
index dbd8f8bf4f..462c111e13 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -32,7 +32,7 @@ routines := herror inet_addr inet_ntop inet_pton nsap_addr res_init \
 	    resolv_context resolv_conf
 
 tests = tst-aton tst-leaks tst-inet_ntop
-xtests = tst-leaks2
+tests-container = tst-leaks2
 
 tests-internal += tst-inet_aton_exact
 
@@ -125,9 +125,8 @@ endif
 
 ifeq ($(run-built-tests),yes)
 ifneq (no,$(PERL))
-tests-special += $(objpfx)mtrace-tst-leaks.out
-xtests-special += $(objpfx)mtrace-tst-leaks2.out
-tests-special += $(objpfx)mtrace-tst-resolv-res_ninit.out
+tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \
+		 $(objpfx)mtrace-tst-resolv-res_ninit.out
 endif
 endif
 
diff --git a/resolv/tst-leaks2.c b/resolv/tst-leaks2.c
index a2f5db3adc..49a5d11d49 100644
--- a/resolv/tst-leaks2.c
+++ b/resolv/tst-leaks2.c
@@ -21,6 +21,7 @@
 #include <mcheck.h>
 #include <netdb.h>
 #include <resolv.h>
+#include <support/check.h>
 
 static int
 do_test (void)
@@ -28,8 +29,9 @@ do_test (void)
   mtrace ();
   for (int i = 0; i < 20; ++i)
     {
-      res_init ();
-      gethostbyname ("www.gnu.org");
+      TEST_VERIFY_EXIT (res_init () == 0);
+      if (gethostbyname ("www.gnu.org") == NULL)
+	FAIL_EXIT1 ("%s\n", hstrerror (h_errno));
     }
   return 0;
 }
diff --git a/resolv/tst-leaks2.root/etc/hosts b/resolv/tst-leaks2.root/etc/hosts
new file mode 100644
index 0000000000..65151f27f5
--- /dev/null
+++ b/resolv/tst-leaks2.root/etc/hosts
@@ -0,0 +1 @@
+192.0.2.1 www.gnu.org
diff --git a/resolv/tst-leaks2.root/etc/nsswitch.conf b/resolv/tst-leaks2.root/etc/nsswitch.conf
new file mode 100644
index 0000000000..5b0c6a4199
--- /dev/null
+++ b/resolv/tst-leaks2.root/etc/nsswitch.conf
@@ -0,0 +1 @@
+hosts: files