public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: YunQiang Su <wzssyqa@gmail.com>
To: Chen Li <chenli@uniontech.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH] skip testing time before epoch on mips
Date: Mon, 8 Mar 2021 14:41:36 +0800	[thread overview]
Message-ID: <CAKcpw6W_-L-cNG-d7YavGoSJa9R4O0v-BgLR5b2b03rXKnc_iQ@mail.gmail.com> (raw)
In-Reply-To: <87ft16ywyr.wl-chenli@uniontech.com>

Chen Li <chenli@uniontech.com> 于2021年3月8日周一 下午2:35写道:
>
>
> When execute libstdc++ testcases on mips, I notice that last_write_time
> alawys failed, and the failed VERIFY is  "VERIFY(
> approx_equal(last_write_time(f.path), time) );" where testing time before
> than epoch.
>
> Below is the minimal case:
>
> ```
> // gcc a.c
> int main()
> {
>         struct timespec times[2] = {{1, UTIME_OMIT}, {-1201, 985000000}};
>         utimensat(AT_FDCWD, "test", times, 0);
>
> }
> ```
>
> $ touch test && gcc a.c && ./a.out && stat test
>   File: test
>   Size: 0               Blocks: 0          IO Block: 4096   regular empty file
> Device: 805h/2053d      Inode: 1056841     Links: 1
> Access: (0644/-rw-r--r--)  Uid: ( 1000/  deepin)   Gid: ( 1000/  deepin)
> Access: 2021-03-08 13:52:55.966354501 +0800
> Modify: 2106-02-07 14:08:15.985000000 +0800
> Change: 2021-03-08 13:52:56.907782193 +0800
>  Birth: -
>
> Undoubtedly, mtime's type is unsigned somewhere on mips.
>

It only has this problem on mips64.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983769

> After debuging kernel, it turns out that mtime is always -1201 in
> ext4_setattr, cp_new_stat, newlstat and etc, so the problem should not
> occur in kernel space.
>
> go back to user space via copy_to_user, I finally found mips used
> "unsigned int st_mtime_sec;" in struct kernel_stat, which is used to
> receive -1201 from kernel.
>
> Maybe sparc also suffers from this problem, but I have no machine to
> verify.
> ---
>  .../testsuite/27_io/filesystem/operations/last_write_time.cc    | 2 ++
>  .../experimental/filesystem/operations/last_write_time.cc       | 2 ++
>  2 files changed, 4 insertions(+)
>
> diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
> index 6ae64c482b6..72272d4e781 100644
> --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
> +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
> @@ -200,11 +200,13 @@ test02()
>    VERIFY( approx_equal(last_write_time(f.path), time) );
>
>    ec = bad_ec;
> +  #ifndef __mips__
>    // A time before than the epoch
>    time -= chrono::milliseconds(1000 * 60 * 20 + 15);
>    last_write_time(f.path, time, ec);
>    VERIFY( !ec );
>    VERIFY( approx_equal(last_write_time(f.path), time) );
> +  #endif
>  }
>
>  int
> diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc
> index 536ab1f28f6..6fb490a6bc3 100644
> --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc
> +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc
> @@ -165,11 +165,13 @@ test02()
>    VERIFY( !ec );
>    VERIFY( approx_equal(last_write_time(f.path), time) );
>
> +  #ifndef __mips__
>    ec = bad_ec;
>    time -= chrono::milliseconds(1000 * 60 * 10 + 15);
>    last_write_time(f.path, time, ec);
>    VERIFY( !ec );
>    VERIFY( approx_equal(last_write_time(f.path), time) );
> +  #endif
>  }
>
>  int
> --
> 2.30.0
>
>
>


-- 
YunQiang Su

  reply	other threads:[~2021-03-08  6:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08  6:35 Chen Li
2021-03-08  6:41 ` YunQiang Su [this message]
2021-03-08 10:57 ` Jonathan Wakely
2021-03-08 11:15   ` YunQiang Su
2021-03-10  3:31 Chen Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKcpw6W_-L-cNG-d7YavGoSJa9R4O0v-BgLR5b2b03rXKnc_iQ@mail.gmail.com \
    --to=wzssyqa@gmail.com \
    --cc=chenli@uniontech.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).