unix: compare Stat_t members when checking Stat vs. Fstatat in TestFstatat

TestFstatat regularly fails on the dragonfly-amd64 builder due to
mismatching Stat_t info returned by the calls to Fstatat vs. Stat (most
likely due to Atime changing). Fix the test by just comparing some well
known members. This was already fixed for the Lstat call in CL 212417.

Fixes golang/go#42208

Change-Id: I3e241470d373338b9716bb9ce0265a105db2720d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/265018
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Tobias Klauser
2020-10-26 13:34:11 +00:00
committed by Tobias Klauser
parent 9f70ab9862
commit 418715ba6f
+23 -21
View File
@@ -653,6 +653,27 @@ func TestGetwd(t *testing.T) {
}
}
func compareStat_t(t *testing.T, otherStat string, st1, st2 *unix.Stat_t) {
if st2.Dev != st1.Dev {
t.Errorf("%s/Fstatat: got dev %v, expected %v", otherStat, st2.Dev, st1.Dev)
}
if st2.Ino != st1.Ino {
t.Errorf("%s/Fstatat: got ino %v, expected %v", otherStat, st2.Ino, st1.Ino)
}
if st2.Mode != st1.Mode {
t.Errorf("%s/Fstatat: got mode %v, expected %v", otherStat, st2.Mode, st1.Mode)
}
if st2.Uid != st1.Uid {
t.Errorf("%s/Fstatat: got uid %v, expected %v", otherStat, st2.Uid, st1.Uid)
}
if st2.Gid != st1.Gid {
t.Errorf("%s/Fstatat: got gid %v, expected %v", otherStat, st2.Gid, st1.Gid)
}
if st2.Size != st1.Size {
t.Errorf("%s/Fstatat: got size %v, expected %v", otherStat, st2.Size, st1.Size)
}
}
func TestFstatat(t *testing.T) {
defer chtmpdir(t)()
@@ -670,9 +691,7 @@ func TestFstatat(t *testing.T) {
t.Fatalf("Fstatat: %v", err)
}
if st1 != st2 {
t.Errorf("Fstatat: returned stat does not match Stat")
}
compareStat_t(t, "Stat", &st1, &st2)
err = os.Symlink("file1", "symlink1")
if err != nil {
@@ -689,24 +708,7 @@ func TestFstatat(t *testing.T) {
t.Fatalf("Fstatat: %v", err)
}
if st2.Dev != st1.Dev {
t.Errorf("Fstatat: got dev %v, expected %v", st2.Dev, st1.Dev)
}
if st2.Ino != st1.Ino {
t.Errorf("Fstatat: got ino %v, expected %v", st2.Ino, st1.Ino)
}
if st2.Mode != st1.Mode {
t.Errorf("Fstatat: got mode %v, expected %v", st2.Mode, st1.Mode)
}
if st2.Uid != st1.Uid {
t.Errorf("Fstatat: got uid %v, expected %v", st2.Uid, st1.Uid)
}
if st2.Gid != st1.Gid {
t.Errorf("Fstatat: got gid %v, expected %v", st2.Gid, st1.Gid)
}
if st2.Size != st1.Size {
t.Errorf("Fstatat: got size %v, expected %v", st2.Size, st1.Size)
}
compareStat_t(t, "Lstat", &st1, &st2)
}
func TestFchmodat(t *testing.T) {