Fix tst-canon-bz26341 when the glibc build current working directory is itself using symlinks

Message ID 20210810130121.GA62219@ncerndobedev6097.etv.nce.amadeus.net
State Committed
Headers
Series Fix tst-canon-bz26341 when the glibc build current working directory is itself using symlinks |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Romain Geissler Aug. 10, 2021, 1:01 p.m. UTC
  Hi,

I am seeing test failures with tst-canon-bz26341. Using strace I found out that
the problem comes from when change the current working directory to my glibc build
directory, I use a path with is using itself symlinks. So at the beginning of the
test the "filename" variable needs to be canonicalized properly to make it pass in
these conditions.

Tested on x86-64.

Cheers,
Romain

From 99ef44560977e366c64912cfcb2a6535a0614c50 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@amadeus.com>
Date: Tue, 10 Aug 2021 12:40:41 +0000
Subject: [PATCH] Fix tst-canon-bz26341 when the glibc build current working
 directory is itself using symlinks.

---
 stdlib/tst-canon-bz26341.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Adhemerval Zanella Aug. 19, 2021, 12:35 p.m. UTC | #1
On 10/08/2021 10:01, Romain GEISSLER via Libc-alpha wrote:
> Hi,
> 
> I am seeing test failures with tst-canon-bz26341. Using strace I found out that
> the problem comes from when change the current working directory to my glibc build
> directory, I use a path with is using itself symlinks. So at the beginning of the
> test the "filename" variable needs to be canonicalized properly to make it pass in
> these conditions.
> 
> Tested on x86-64.

LGTM, with a minor style fix below.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 
> Cheers,
> Romain
> 
> From 99ef44560977e366c64912cfcb2a6535a0614c50 Mon Sep 17 00:00:00 2001
> From: Romain Geissler <romain.geissler@amadeus.com>
> Date: Tue, 10 Aug 2021 12:40:41 +0000
> Subject: [PATCH] Fix tst-canon-bz26341 when the glibc build current working
>  directory is itself using symlinks.
> 
> ---
>  stdlib/tst-canon-bz26341.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/stdlib/tst-canon-bz26341.c b/stdlib/tst-canon-bz26341.c
> index acb0fd4ec30..171ec0dc45a 100644
> --- a/stdlib/tst-canon-bz26341.c
> +++ b/stdlib/tst-canon-bz26341.c
> @@ -45,6 +45,12 @@ create_link (void)
>    TEST_VERIFY_EXIT (fd != -1);
>    xclose (fd);
>  
> +  /* Make filename a canonical path. */

Double space after period.

> +  char *saved_filename = filename;
> +  filename = realpath (filename, NULL);
> +  free (saved_filename);
> +  TEST_VERIFY (filename != NULL);
> +
>    /* Create MAXLINKS symbolic links to the temporary filename.
>       On exit, linkname has the last link created.  */
>    char *prevlink = filename;
>
  

Patch

diff --git a/stdlib/tst-canon-bz26341.c b/stdlib/tst-canon-bz26341.c
index acb0fd4ec30..171ec0dc45a 100644
--- a/stdlib/tst-canon-bz26341.c
+++ b/stdlib/tst-canon-bz26341.c
@@ -45,6 +45,12 @@  create_link (void)
   TEST_VERIFY_EXIT (fd != -1);
   xclose (fd);
 
+  /* Make filename a canonical path. */
+  char *saved_filename = filename;
+  filename = realpath (filename, NULL);
+  free (saved_filename);
+  TEST_VERIFY (filename != NULL);
+
   /* Create MAXLINKS symbolic links to the temporary filename.
      On exit, linkname has the last link created.  */
   char *prevlink = filename;