summaryrefslogtreecommitdiff
path: root/internal/syscallcompat/sys_common_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/syscallcompat/sys_common_test.go')
-rw-r--r--internal/syscallcompat/sys_common_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/syscallcompat/sys_common_test.go b/internal/syscallcompat/sys_common_test.go
index 455774f..db6719e 100644
--- a/internal/syscallcompat/sys_common_test.go
+++ b/internal/syscallcompat/sys_common_test.go
@@ -34,6 +34,35 @@ func TestReadlinkat(t *testing.T) {
}
}
+func TestOpenat(t *testing.T) {
+ _, err := Openat(tmpDirFd, "testOpenAt", 0, 0)
+ if err == nil {
+ t.Errorf("should have failed")
+ }
+ fd, err := os.Create(tmpDir + "/testOpenAt")
+ if err != nil {
+ t.Fatal(err)
+ }
+ fd.Close()
+ rawFd, err := Openat(tmpDirFd, "testOpenAt", 0, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer syscall.Close(rawFd)
+ if rawFd < 0 {
+ t.Fatalf("rawFd=%d", rawFd)
+ }
+ // Test with absolute path
+ rawFd, err = Openat(-1, tmpDir+"/testOpenAt", 0, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer syscall.Close(rawFd)
+ if rawFd < 0 {
+ t.Fatalf("rawFd=%d", rawFd)
+ }
+}
+
func TestFchmodat(t *testing.T) {
regular := "TestFchmodat_Regular"
f, err := os.OpenFile(tmpDir+"/"+regular, os.O_CREATE|os.O_WRONLY, 0000)