From cf1455657ec916ecd78c9d2c3bcbbf6608e6c158 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 15 Oct 2015 22:29:06 +0000 Subject: Do not leave files behind in /tmp from testing. 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). * io/test-lfs.c (do_prepare): Do not call add_temp_file until after mkstemp64. * login/tst-utmp.c (do_prepare): Likewise. * rt/tst-aio.c (do_prepare): Likewise. * rt/tst-aio64.c (do_prepare): Likewise. --- rt/tst-aio.c | 2 +- rt/tst-aio64.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'rt') diff --git a/rt/tst-aio.c b/rt/tst-aio.c index 783907ea80..007ef6c68f 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 3a9ae797b1..b315eec727 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); } -- cgit 1.4.1