From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23979 invoked by alias); 21 Jul 2004 18:07:23 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 23903 invoked from network); 21 Jul 2004 18:07:22 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.15.26) by sourceware.org with SMTP; 21 Jul 2004 18:07:22 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id i6LFpO3j002054; Wed, 21 Jul 2004 17:51:24 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id i6LFpOZp002052; Wed, 21 Jul 2004 17:51:24 +0200 Date: Wed, 21 Jul 2004 18:07:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] tst-leaks2 Message-ID: <20040721155123.GR30497@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek References: <20040721152324.GQ30497@sunsite.ms.mff.cuni.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040721152324.GQ30497@sunsite.ms.mff.cuni.cz> User-Agent: Mutt/1.4.1i X-SW-Source: 2004-07/txt/msg00044.txt.bz2 On Wed, Jul 21, 2004 at 05:23:24PM +0200, Jakub Jelinek wrote: > leaks memory and if IPv6 is enabled also filehandles. Here is a testcase for make xcheck: 2004-07-21 Jakub Jelinek * resolv/Makefile: Add rules to build and run tst-leaks2. * resolv/tst-leaks2.c: New test. --- libc/resolv/Makefile.jj 2004-01-12 10:52:38.000000000 +0100 +++ libc/resolv/Makefile 2004-07-21 20:00:47.727921163 +0200 @@ -33,8 +33,9 @@ routines := herror inet_addr inet_ntop i res_hconf res_libc res-state tests = tst-aton tst-leaks +xtests = tst-leaks2 -generate := mtrace-tst-leaks tst-leaks.mtrace +generate := mtrace-tst-leaks tst-leaks.mtrace tst-leaks2.mtrace include ../Makeconfig @@ -65,7 +66,8 @@ ifeq (yesyes,$(build-shared)$(have-threa tests: $(objpfx)ga_test endif -generated := mtrace-tst-leaks tst-leaks.mtrace +generated := mtrace-tst-leaks tst-leaks.mtrace \ + mtrace-tst-leaks2 tst-leaks2.mtrace include ../Rules @@ -104,3 +106,12 @@ ifneq (no,$(PERL)) tests: $(objpfx)mtrace-tst-leaks endif endif + +tst-leaks2-ENV = MALLOC_TRACE=$(objpfx)tst-leaks2.mtrace +$(objpfx)mtrace-tst-leaks2: $(objpfx)tst-leaks2.out + $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks2.mtrace > $@ +ifeq (no,$(cross-compiling)) +ifneq (no,$(PERL)) +xtests: $(objpfx)mtrace-tst-leaks2 +endif +endif --- libc/resolv/tst-leaks2.c.jj 2004-07-21 19:55:46.287620269 +0200 +++ libc/resolv/tst-leaks2.c 2004-07-21 20:03:47.549480733 +0200 @@ -0,0 +1,42 @@ +/* Tests for res_init in libresolv + Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#undef gethostbyname + +#include +#include +#include + +/* Prototype for our test function. */ +extern int do_test (int argc, char *argv[]); + +/* This defines the `main' function and some more. */ +#include + +int +do_test (int argc, char *argv[]) +{ + mtrace (); + for (int i = 0; i < 20; ++i) + { + res_init (); + gethostbyname ("www.gnu.org"); + } + return 0; +} Jakub