summaryrefslogtreecommitdiff
path: root/internal/syscallcompat/sys_common_test.go
diff options
context:
space:
mode:
authorSebastian Lackner2019-01-14 03:00:49 +0100
committerrfjakob2019-01-14 21:27:28 +0100
commita9d8eb49ef91c31fddc3e4f2f76e9b98e1a52a1d (patch)
tree1ceec94d92a33d4ff8282f8baef80aafbdb21e3d /internal/syscallcompat/sys_common_test.go
parent4134ff7570906d38d519b1aad33cd3e97685e92f (diff)
syscallcompat: Drop Fstatat emulation on macOS.
Diffstat (limited to 'internal/syscallcompat/sys_common_test.go')
-rw-r--r--internal/syscallcompat/sys_common_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/syscallcompat/sys_common_test.go b/internal/syscallcompat/sys_common_test.go
index e1c7b24..14e1b3f 100644
--- a/internal/syscallcompat/sys_common_test.go
+++ b/internal/syscallcompat/sys_common_test.go
@@ -273,3 +273,38 @@ func TestMkdirat(t *testing.T) {
t.Fatalf("mkdirat did not create a directory")
}
}
+
+func TestFstatat(t *testing.T) {
+ var st unix.Stat_t
+ // stat a normal file (size 3)
+ f, err := os.Create(tmpDir + "/fstatat")
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = f.Write([]byte("foo"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+ err = Fstatat(tmpDirFd, "fstatat", &st, unix.AT_SYMLINK_NOFOLLOW)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if st.Size != 3 {
+ t.Errorf("wrong file size: %d", st.Size)
+ }
+ // stat a symlink and check that the size matches the length of the
+ // symlink target. This proves that we have stat'ed the symlink itself.
+ err = os.Symlink(tmpDir+"/fstatat", tmpDir+"/fstatatSymlink")
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = Fstatat(tmpDirFd, "fstatatSymlink", &st, unix.AT_SYMLINK_NOFOLLOW)
+ if err != nil {
+ t.Fatal(err)
+ }
+ expectedSize := int64(len(tmpDir + "/fstatat"))
+ if st.Size != expectedSize {
+ t.Errorf("symlink size: expected=%d, got=%d", expectedSize, st.Size)
+ }
+}