mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-01 14:47:28 -04:00
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: Ian Lance Taylor <iant@golang.org> Reviewed-by: jimmy frasche <soapboxcicero@gmail.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
a200a19cb9
commit
c4afb3effa
@@ -142,8 +142,14 @@ func TestUtimesNanoAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only check Mtim, Atim might not be supported by the underlying filesystem
|
// Only check Mtim, Atim might not be supported by the underlying filesystem
|
||||||
if st.Mtim != ts[1] {
|
expected := ts[1]
|
||||||
t.Errorf("UtimesNanoAt: wrong mtime: %v", st.Mtim)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user