From patchwork Thu Oct 15 20:50:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 530893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 598CA1402DD for ; Fri, 16 Oct 2015 07:51:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=WNjRJYeE; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=MuWi6D7J9mymK2X3YZXlB0rGMPi/i Qa/w3eSd+YDENUa1dXXHlchCSNTCZgIo1/3AauaZ7e6WlI/kMXMwEZeWTnpYwAkT mdbwrTvEEK83JIClmciAT10BiD1U9ulWHMu8i6AvjpdxqJjebsBZpJkl26Zl5I2+ 9iBFTbQX0aSvd4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=yzeNpJtRluHoK+rPLqwD7eVqynY=; b=WNj RJYeE/25La9hCuKhIWoG7StykFOp2HD6zkMw1u2NcbrekrcPE43PpiiCPx/CNcJi 3OhnSPwI0HISxUbbqq52AjOX+wbrz/qkpICn1r+dFXedBD17ElGiCytuEgY17zwt hpyJmHbRHxflYVQ/zMWsogL0eXpWu0HUpgfIv0PY= Received: (qmail 89945 invoked by alias); 15 Oct 2015 20:50:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 89842 invoked by uid 89); 15 Oct 2015 20:50:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FILL_THIS_FORM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Thu, 15 Oct 2015 20:50:50 +0000 From: Joseph Myers To: Subject: Do not leave files behind in /tmp from testing Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 I noticed that glibc testsuite runs left several files behind in /tmp (or TMPDIR, if different). The problem was testcases that generate a template for mkstemp / mkstemp64, ending with XXXXXX, then pass that template to add_temp_file before calling mkstemp / mkstemp64, meaning that the template ending with XXXXXX is stored in the list of temporary files to delete (add_temp_file uses strdup so that the original string doesn't need to stay live), not the actual filename as determined by mkstemp / mkstemp64. This patch fixes those tests to call add_temp_file later. Tested for x86_64 (that the files are no longer left behind by a testsuite run and the modified tests still pass). 2015-10-15 Joseph Myers * io/test-lfs.c (do_prepare): Do not call add_temp_file until after mkstemp64. * io/tst-fcntl.c (do_prepare): Do not call add_temp_file here. (do_test): Call add_temp_file here instead. * login/tst-utmp.c (do_prepare): Do not call add_temp_file until after mkstemp. * rt/tst-aio.c (do_prepare): Likewise. * rt/tst-aio64.c (do_prepare): Likewise. diff --git a/io/test-lfs.c b/io/test-lfs.c index b6ebae4..09310a4 100644 --- a/io/test-lfs.c +++ b/io/test-lfs.c @@ -56,7 +56,6 @@ do_prepare (int argc, char *argv[]) name = malloc (name_len + sizeof ("/lfsXXXXXX")); mempcpy (mempcpy (name, test_dir, name_len), "/lfsXXXXXX", sizeof ("/lfsXXXXXX")); - add_temp_file (name); /* Open our test file. */ fd = mkstemp64 (name); @@ -71,6 +70,7 @@ do_prepare (int argc, char *argv[]) else error (EXIT_FAILURE, errno, "cannot create temporary file"); } + add_temp_file (name); if (getrlimit64 (RLIMIT_FSIZE, &rlim) != 0) { diff --git a/io/tst-fcntl.c b/io/tst-fcntl.c index dfdb42e..c7b8275 100644 --- a/io/tst-fcntl.c +++ b/io/tst-fcntl.c @@ -47,7 +47,6 @@ do_prepare (int argc, char *argv[]) name = malloc (name_len + sizeof ("/fcntlXXXXXX")); mempcpy (mempcpy (name, test_dir, name_len), "/fcntlXXXXXX", sizeof ("/fcntlXXXXXX")); - add_temp_file (name); } @@ -68,6 +67,7 @@ do_test (int argc, char *argv[]) printf ("cannot open temporary file: %m\n"); return 1; } + add_temp_file (name); if (fstat64 (fd, &st) != 0) { printf ("cannot stat test file: %m\n"); diff --git a/login/tst-utmp.c b/login/tst-utmp.c index a69a556..a029003 100644 --- a/login/tst-utmp.c +++ b/login/tst-utmp.c @@ -65,12 +65,12 @@ do_prepare (int argc, char *argv[]) name = malloc (name_len + sizeof ("/utmpXXXXXX")); mempcpy (mempcpy (name, test_dir, name_len), "/utmpXXXXXX", sizeof ("/utmpXXXXXX")); - add_temp_file (name); /* Open our test file. */ fd = mkstemp (name); if (fd == -1) error (EXIT_FAILURE, errno, "cannot open test file `%s'", name); + add_temp_file (name); } struct utmp entry[] = diff --git a/rt/tst-aio.c b/rt/tst-aio.c index 783907e..007ef6c 100644 --- a/rt/tst-aio.c +++ b/rt/tst-aio.c @@ -54,12 +54,12 @@ do_prepare (int argc, char *argv[]) name = malloc (name_len + sizeof ("/aioXXXXXX")); mempcpy (mempcpy (name, test_dir, name_len), "/aioXXXXXX", sizeof ("/aioXXXXXX")); - add_temp_file (name); /* Open our test file. */ fd = mkstemp (name); if (fd == -1) error (EXIT_FAILURE, errno, "cannot open test file `%s'", name); + add_temp_file (name); } diff --git a/rt/tst-aio64.c b/rt/tst-aio64.c index 3a9ae79..b315eec 100644 --- a/rt/tst-aio64.c +++ b/rt/tst-aio64.c @@ -55,12 +55,12 @@ do_prepare (int argc, char *argv[]) name = malloc (name_len + sizeof ("/aioXXXXXX")); mempcpy (mempcpy (name, test_dir, name_len), "/aioXXXXXX", sizeof ("/aioXXXXXX")); - add_temp_file (name); /* Open our test file. */ fd = mkstemp (name); if (fd == -1) error (EXIT_FAILURE, errno, "cannot open test file `%s'", name); + add_temp_file (name); }