[PATCH v2] io/tst-stat.c: Use a temporary directory for symlink test

Andreas K. Huettel dilfridge@gentoo.org
Sat Jul 19 19:12:40 GMT 2025


Am Samstag, 19. Juli 2025, 02:03:04 Mitteleuropäische Sommerzeit schrieb H.J. Lu:
> Call support_create_temp_directory to create a temporary directory for
> symlink test, instead of a fixed file in the glibc source tree, to avoid
> the race condition when there are more than one glibc tests running at the
> same time with the same glibc source tree.  This fixes BZ #33178.

OK from me

> 
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  io/tst-stat.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/io/tst-stat.c b/io/tst-stat.c
> index aeea435ca1..5e0bfcc30e 100644
> --- a/io/tst-stat.c
> +++ b/io/tst-stat.c
> @@ -27,6 +27,7 @@
>  #include <sys/sysmacros.h>
>  #include <stdio.h>
>  #include <unistd.h>
> +#include <stdlib.h>
>  
>  static void
>  stat_check (int fd, const char *path, struct stat *st)
> @@ -78,7 +79,8 @@ static int
>  do_test (void)
>  {
>    char *path;
> -  const char *linkame = "tst-fstat.linkname";
> +  char *tempdir = support_create_temp_directory ("tst-stat-");
> +  char *linkname = xasprintf ("%s/tst-fstat.linkname", tempdir);
>    int fd = create_temp_file ("tst-fstat.", &path);
>    TEST_VERIFY_EXIT (fd >= 0);
>    support_write_file_string (path, "abc");
> @@ -122,9 +124,12 @@ do_test (void)
>  	}
>      }
>  
> -  TEST_COMPARE (symlink ("tst-fstat.target", linkame), 0);
> -  add_temp_file (linkame);
> -  fstatat_link (linkame, &st);
> +  TEST_COMPARE (symlink ("tst-fstat.target", linkname), 0);
> +  add_temp_file (linkname);
> +  fstatat_link (linkname, &st);
> +
> +  free (linkname);
> +  free (tempdir);
>  
>    return 0;
>  }
> 


-- 
Andreas K. Hüttel
dilfridge@gentoo.org
Gentoo Linux developer 
(council, comrel, toolchain, base-system, perl, libreoffice)
https://wiki.gentoo.org/wiki/User:Dilfridge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250719/2a02dc2d/attachment.sig>


More information about the Libc-alpha mailing list