From patchwork Fri Nov 20 12:06:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 41139 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D0D31396D814; Fri, 20 Nov 2020 12:06:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0D31396D814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605873999; bh=SJY/NUJiOa/n/dJLc3wgNifB4vJyqE7ja/ouVr4Ftig=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=EwRQUBg5Nq0PtidOuPaVKNjvcRlyFbwnWLlrNBye8LIuaRNsqUWqlJwpy1gSY0EOy jFAokp956CWe2r9BcsBa0o31T1Z6DmKZ3eEoxUq9QWCgIDoMOvg1W6l87v/Cc2UeuO Dc4ebjky+PwN3Di4MBsKkakipmqhbf/HrwNcazFo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id E3CDF3870881 for ; Fri, 20 Nov 2020 12:06:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E3CDF3870881 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AKC1TdV045800 for ; Fri, 20 Nov 2020 07:06:36 -0500 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 34xd1kgueg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 20 Nov 2020 07:06:35 -0500 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AKBw2Iq002723 for ; Fri, 20 Nov 2020 12:06:33 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 34weby1n86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 20 Nov 2020 12:06:33 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AKC6USH6750954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Nov 2020 12:06:31 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D86ECA4053; Fri, 20 Nov 2020 12:06:30 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B81D1A404D; Fri, 20 Nov 2020 12:06:30 +0000 (GMT) Received: from t3560005.lnxne.boe (unknown [9.152.108.100]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 20 Nov 2020 12:06:30 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCH] Use libnss_files.so for tests posix/bug-ga2 and resolv/tst-leaks2 [BZ #26821] Date: Fri, 20 Nov 2020 13:06:29 +0100 Message-Id: <20201120120629.3211591-1-stli@linux.ibm.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-20_04:2020-11-20, 2020-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 phishscore=0 clxscore=1015 suspectscore=4 bulkscore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011200079 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Stefan Liebler via Libc-alpha From: Stefan Liebler Reply-To: Stefan Liebler Cc: Stefan Liebler Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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. --- posix/Makefile | 6 +++--- posix/bug-ga2.c | 13 +++++++------ posix/bug-ga2.root/etc/hosts | 1 + posix/bug-ga2.root/etc/nsswitch.conf | 2 ++ posix/bug-ga2.root/etc/services | 1 + resolv/Makefile | 7 +++---- resolv/tst-leaks2.c | 6 ++++-- resolv/tst-leaks2.root/etc/hosts | 1 + resolv/tst-leaks2.root/etc/nsswitch.conf | 1 + 9 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 posix/bug-ga2.root/etc/hosts create mode 100644 posix/bug-ga2.root/etc/nsswitch.conf create mode 100644 posix/bug-ga2.root/etc/services create mode 100644 resolv/tst-leaks2.root/etc/hosts create mode 100644 resolv/tst-leaks2.root/etc/nsswitch.conf diff --git a/posix/Makefile b/posix/Makefile index 693082ed28..fa2d0675cd 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -106,7 +106,8 @@ tests := test-errno tstgetopt testfnm runtests runptests \ tests-internal := bug-regex5 bug-regex20 bug-regex33 \ tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \ tst-glob_lstat_compat tst-spawn4-compat -xtests := bug-ga2 tst-getaddrinfo4 tst-getaddrinfo5 +tests-container := bug-ga2 +xtests := tst-getaddrinfo4 tst-getaddrinfo5 ifeq (yes,$(build-shared)) test-srcs := globtest tests += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3 @@ -153,8 +154,7 @@ tests-special += $(objpfx)bug-regex2-mem.out $(objpfx)bug-regex14-mem.out \ $(objpfx)tst-boost-mem.out $(objpfx)tst-getconf.out \ $(objpfx)bug-glob2-mem.out $(objpfx)tst-vfork3-mem.out \ $(objpfx)tst-fnmatch-mem.out $(objpfx)bug-regex36-mem.out \ - $(objpfx)tst-glob-tilde-mem.out -xtests-special += $(objpfx)bug-ga2-mem.out + $(objpfx)tst-glob-tilde-mem.out $(objpfx)bug-ga2-mem.out endif include ../Rules diff --git a/posix/bug-ga2.c b/posix/bug-ga2.c index 5ea759b8ce..712e40de48 100644 --- a/posix/bug-ga2.c +++ b/posix/bug-ga2.c @@ -3,9 +3,10 @@ #include #include #include +#include -int -main (void) +static int +do_test (void) { struct addrinfo hints, *res; int i, ret; @@ -20,11 +21,11 @@ main (void) ret = getaddrinfo ("www.gnu.org", "http", &hints, &res); if (ret) - { - printf ("%s\n", gai_strerror (ret)); - return 1; - } + FAIL_EXIT1 ("%s\n", gai_strerror (ret)); + freeaddrinfo (res); } return 0; } + +#include diff --git a/posix/bug-ga2.root/etc/hosts b/posix/bug-ga2.root/etc/hosts new file mode 100644 index 0000000000..65151f27f5 --- /dev/null +++ b/posix/bug-ga2.root/etc/hosts @@ -0,0 +1 @@ +192.0.2.1 www.gnu.org diff --git a/posix/bug-ga2.root/etc/nsswitch.conf b/posix/bug-ga2.root/etc/nsswitch.conf new file mode 100644 index 0000000000..fd2edb44dc --- /dev/null +++ b/posix/bug-ga2.root/etc/nsswitch.conf @@ -0,0 +1,2 @@ +services: files +hosts: files diff --git a/posix/bug-ga2.root/etc/services b/posix/bug-ga2.root/etc/services new file mode 100644 index 0000000000..94d4f07612 --- /dev/null +++ b/posix/bug-ga2.root/etc/services @@ -0,0 +1 @@ +http 80/tcp 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 #include #include +#include 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