| // Copyright 2018 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // stringsFromByteSlice converts a sequence of attributes to a []string. |
| // On Darwin, each entry is a NULL-terminated string. |
| func stringsFromByteSlice(buf []byte) []string { |
| result = append(result, string(buf[off:i])) |
| func TestUtimesNanoAt(t *testing.T) { |
| err := os.Symlink("nonexisting", symlink) |
| err = unix.UtimesNanoAt(unix.AT_FDCWD, symlink, ts, unix.AT_SYMLINK_NOFOLLOW) |
| t.Fatalf("UtimesNanoAt: %v", err) |
| err = unix.Lstat(symlink, &st) |
| t.Fatalf("Lstat: %v", err) |
| // Only check Mtimespec, Atimespec might not be supported by the underlying filesystem |
| if st.Mtimespec.Nsec == 0 { |
| // Some filesystems only support 1-second time stamp resolution |
| // and will always set Nsec to 0. |
| if st.Mtimespec != expected { |
| t.Errorf("UtimesNanoAt: wrong mtime: got %v, expected %v", st.Mtimespec, expected) |