Commit bb1b7fe5 authored by Tobias Klauser's avatar Tobias Klauser Committed by Tobias Klauser

unix: add test for UtimesNanoAt on Linux

Add a test for UtimesNanoAt which makes sure the timestamp of a symlink
is updated.

Change-Id: I819e43db1d390fb37f011b34e58ff9d3d06595f1
Reviewed-on: https://go-review.googlesource.com/72377
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent a1a1f174
......@@ -184,6 +184,38 @@ func TestUtime(t *testing.T) {
}
}
func TestUtimesNanoAt(t *testing.T) {
defer chtmpdir(t)()
symlink := "symlink1"
os.Remove(symlink)
err := os.Symlink("nonexisting", symlink)
if err != nil {
t.Fatal(err)
}
ts := []unix.Timespec{
{Sec: 1111, Nsec: 2222},
{Sec: 3333, Nsec: 4444},
}
err = unix.UtimesNanoAt(unix.AT_FDCWD, symlink, ts, unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
t.Fatalf("UtimesNanoAt: %v", err)
}
var st unix.Stat_t
err = unix.Lstat(symlink, &st)
if err != nil {
t.Fatalf("Lstat: %v", err)
}
if st.Atim != ts[0] {
t.Errorf("UtimesNanoAt: wrong atime: %v", st.Atim)
}
if st.Mtim != ts[1] {
t.Errorf("UtimesNanoAt: wrong mtime: %v", st.Mtim)
}
}
func TestGetrlimit(t *testing.T) {
var rlim unix.Rlimit
err := unix.Getrlimit(unix.RLIMIT_AS, &rlim)
......
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