From 5a3cf8467b4e9da13d4ac22ee4e4906aec6f9dc0 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 23 Dec 2019 10:27:52 +0100 Subject: [PATCH] unix: compare Stat_t members in TestFstatat TestFstatat occasionally fails on some builders due to mismatching Stat_t info returned by the calls to Fstatat (most likely due to Atime changing). Fix the test by just comparing some well known members. Change-Id: I862957ad9d3632173a97d93692a6c672779ac508 Reviewed-on: https://go-review.googlesource.com/c/sys/+/212417 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- unix/syscall_unix_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/unix/syscall_unix_test.go b/unix/syscall_unix_test.go index 1e7ec2ce..cf7ef0b5 100644 --- a/unix/syscall_unix_test.go +++ b/unix/syscall_unix_test.go @@ -680,8 +680,23 @@ func TestFstatat(t *testing.T) { t.Fatalf("Fstatat: %v", err) } - if st1 != st2 { - t.Errorf("Fstatat: returned stat does not match Lstat") + 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) } }