Commit c4afb3ef authored by Tobias Klauser's avatar Tobias Klauser Committed by Brad Fitzpatrick

unix: fix TestUtimesNanoAt for filesystems with 1-second resolution time stamps

Some file systems don't support sub-second time stamp resolution. Handle
these correctly by only checking nanoseconds in case Mtim.Nsec is zero.

Fixes golang/go#26034

Change-Id: I1ab400b8e09b5cfdac6b70a33f676770a48180b1
Reviewed-on: https://go-review.googlesource.com/120816
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarjimmy frasche <soapboxcicero@gmail.com>
parent a200a19c
......@@ -142,8 +142,14 @@ func TestUtimesNanoAt(t *testing.T) {
}
// Only check Mtim, Atim might not be supported by the underlying filesystem
if st.Mtim != ts[1] {
t.Errorf("UtimesNanoAt: wrong mtime: %v", st.Mtim)
expected := ts[1]
if st.Mtim.Nsec == 0 {
// Some filesystems only support 1-second time stamp resolution
// and will always set Nsec to 0.
expected.Nsec = 0
}
if st.Mtim != expected {
t.Errorf("UtimesNanoAt: wrong mtime: expected %v, got %v", expected, st.Mtim)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment