public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] io: Fix sporadic test failures in io/tst-stat
@ 2021-06-10  8:10 Florian Weimer
  2021-06-10 11:47 ` Adhemerval Zanella
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2021-06-10  8:10 UTC (permalink / raw)
  To: libc-alpha; +Cc: Stefan Liebler, Adhemerval Zanella

support_stat_nanoseconds cannot restore the ctime time, and
this may lead to sporadic test failures.  Therefore, probe for
nanoseconds support before the initial statx call.

---
 io/tst-stat.c     | 10 +++++-----
 support/support.h |  3 ++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/io/tst-stat.c b/io/tst-stat.c
index b3e8dc2170..82e965de6a 100644
--- a/io/tst-stat.c
+++ b/io/tst-stat.c
@@ -69,15 +69,15 @@ do_test (void)
   TEST_VERIFY_EXIT (fd >= 0);
   support_write_file_string (path, "abc");
 
-  struct statx stx;
-  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
-
-  test_t tests[] = { stat_check, lstat_check, fstat_check, fstatat_check };
-
   bool check_ns = support_stat_nanoseconds (path);
   if (!check_ns)
     printf ("warning: timestamp with nanoseconds not supported\n");
 
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  test_t tests[] = { stat_check, lstat_check, fstat_check, fstatat_check };
+
   for (int i = 0; i < array_length (tests); i++)
     {
       struct stat st;
diff --git a/support/support.h b/support/support.h
index db264e3db7..874204b7fc 100644
--- a/support/support.h
+++ b/support/support.h
@@ -141,7 +141,8 @@ static __inline bool support_path_support_time64 (const char *path)
 					    0x80000002ULL);
 }
 
-/* Return true if stat supports nanoseconds resolution.  */
+/* Return true if stat supports nanoseconds resolution.  PATH is used
+   for tests and its ctime may change.  */
 extern bool support_stat_nanoseconds (const char *path);
 
 /* Return true if select modify the timeout to reflect the amount of time


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] io: Fix sporadic test failures in io/tst-stat
  2021-06-10  8:10 [PATCH] io: Fix sporadic test failures in io/tst-stat Florian Weimer
@ 2021-06-10 11:47 ` Adhemerval Zanella
  0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella @ 2021-06-10 11:47 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha; +Cc: Stefan Liebler



On 10/06/2021 05:10, Florian Weimer wrote:
> support_stat_nanoseconds cannot restore the ctime time, and
> this may lead to sporadic test failures.  Therefore, probe for
> nanoseconds support before the initial statx call.
> 

LGTM, thanks for catching it.

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

> ---
>  io/tst-stat.c     | 10 +++++-----
>  support/support.h |  3 ++-
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/io/tst-stat.c b/io/tst-stat.c
> index b3e8dc2170..82e965de6a 100644
> --- a/io/tst-stat.c
> +++ b/io/tst-stat.c
> @@ -69,15 +69,15 @@ do_test (void)
>    TEST_VERIFY_EXIT (fd >= 0);
>    support_write_file_string (path, "abc");
>  
> -  struct statx stx;
> -  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
> -
> -  test_t tests[] = { stat_check, lstat_check, fstat_check, fstatat_check };
> -
>    bool check_ns = support_stat_nanoseconds (path);
>    if (!check_ns)
>      printf ("warning: timestamp with nanoseconds not supported\n");
>  
> +  struct statx stx;
> +  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
> +
> +  test_t tests[] = { stat_check, lstat_check, fstat_check, fstatat_check };
> +
>    for (int i = 0; i < array_length (tests); i++)
>      {
>        struct stat st;
> diff --git a/support/support.h b/support/support.h
> index db264e3db7..874204b7fc 100644
> --- a/support/support.h
> +++ b/support/support.h
> @@ -141,7 +141,8 @@ static __inline bool support_path_support_time64 (const char *path)
>  					    0x80000002ULL);
>  }
>  
> -/* Return true if stat supports nanoseconds resolution.  */
> +/* Return true if stat supports nanoseconds resolution.  PATH is used
> +   for tests and its ctime may change.  */
>  extern bool support_stat_nanoseconds (const char *path);
>  
>  /* Return true if select modify the timeout to reflect the amount of time
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-10 11:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10  8:10 [PATCH] io: Fix sporadic test failures in io/tst-stat Florian Weimer
2021-06-10 11:47 ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).