]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Do not leave files behind in /tmp from testing.
authorJoseph Myers <joseph@codesourcery.com>
Thu, 15 Oct 2015 22:29:06 +0000 (22:29 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 15 Oct 2015 22:29:06 +0000 (22:29 +0000)
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.

ChangeLog
io/test-lfs.c
login/tst-utmp.c
rt/tst-aio.c
rt/tst-aio64.c

index 917c4649d932273957c83861725f9baf008cb43e..9465483f832d83a7b55be429bb62b76b5b8e424b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-10-15  Joseph Myers  <joseph@codesourcery.com>
+
+       * 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.
+
 2015-10-15  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
 
        * sysdeps/unix/sysv/linux/powerpc/elision-lock.c
index b6ebae403c850bc0db852121af930d6f6ebab86d..09310a499e31dc4507a5ce54eba676113a76c6ad 100644 (file)
@@ -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)
     {
index a69a556de5fb15aea1cc25cd38442f1b96468e2b..a02900393fdff16f28e2b51687598093ffbe49c4 100644 (file)
@@ -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[] =
index 783907ea8066828d8b456da928b453def929c4a5..007ef6c68f979a7fde12802be55742f9cd3104bb 100644 (file)
@@ -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);
 }
 
 
index 3a9ae797b1e3059764177f73686f4acc70f545bf..b315eec727bbda182e68f9420a2da57af61c684c 100644 (file)
@@ -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);
 }