From c4afb3effaa53fd9a06ca61262dc7ce8df4c081b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 26 Jun 2018 08:41:42 +0200 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor Reviewed-by: jimmy frasche --- unix/syscall_linux_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/unix/syscall_linux_test.go b/unix/syscall_linux_test.go index 4a25ba85..eed17268 100644 --- a/unix/syscall_linux_test.go +++ b/unix/syscall_linux_test.go @@ -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) } }