summaryrefslogtreecommitdiff
path: root/internal/syscallcompat/sys_common_test.go
diff options
context:
space:
mode:
authorSebastian Lackner2019-01-14 02:35:46 +0100
committerrfjakob2019-01-14 21:27:28 +0100
commit42bf6d1c68700a0d5d910c1be42088cc14125fec (patch)
treeccaaefec84822df3547ee8a33f7dc84b5518b6b6 /internal/syscallcompat/sys_common_test.go
parentda557702d713e38a8c6c4c28275724c70988f919 (diff)
syscallcompat: Drop Renameat emulation on macOS.
Diffstat (limited to 'internal/syscallcompat/sys_common_test.go')
-rw-r--r--internal/syscallcompat/sys_common_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/syscallcompat/sys_common_test.go b/internal/syscallcompat/sys_common_test.go
index db6719e..3e38eb2 100644
--- a/internal/syscallcompat/sys_common_test.go
+++ b/internal/syscallcompat/sys_common_test.go
@@ -63,6 +63,43 @@ func TestOpenat(t *testing.T) {
}
}
+func TestRenameat(t *testing.T) {
+ os.Mkdir(tmpDir+"/dir1", 0700)
+ dir1, err := os.Open(tmpDir + "/dir1")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer dir1.Close()
+ os.Mkdir(tmpDir+"/dir2", 0700)
+ dir2, err := os.Open(tmpDir + "/dir2")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer dir2.Close()
+ fd, err := os.Create(tmpDir + "/dir1/f1")
+ if err != nil {
+ t.Fatal(err)
+ }
+ fd.Close()
+ err = Renameat(int(dir1.Fd()), "f1", int(dir2.Fd()), "f2")
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = os.Stat(tmpDir + "/dir2/f2")
+ if err != nil {
+ t.Fatal(err)
+ }
+ // Test with absolute path
+ err = Renameat(-1, tmpDir+"/dir2/f2", -1, tmpDir+"/dir2/f1")
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = os.Stat(tmpDir + "/dir2/f1")
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
func TestFchmodat(t *testing.T) {
regular := "TestFchmodat_Regular"
f, err := os.OpenFile(tmpDir+"/"+regular, os.O_CREATE|os.O_WRONLY, 0000)