aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-12-08 18:49:21 +0100
committerJakob Unterwurzacher2021-12-08 18:49:21 +0100
commit7d60315cd53080e223051a4f16eb3ace3b86e095 (patch)
treeb64657c619a23c90c48d788b0c7fcbd7ac16b157 /tests
parentde22cb1e5dfba8f8b97a5da671bfb2b1a845afb7 (diff)
tests: convert Creat() calls to Open()
Creat() is equivalent to Open(..., O_CREAT|O_WRONLY|O_TRUNC, ...) and MacOS does not have syscall.Creat(). https://github.com/rfjakob/gocryptfs/issues/623
Diffstat (limited to 'tests')
-rw-r--r--tests/cli/cli_test.go2
-rw-r--r--tests/defaults/main_test.go4
-rw-r--r--tests/matrix/concurrency_test.go2
-rw-r--r--tests/plaintextnames/plaintextnames_test.go2
-rw-r--r--tests/root_test/root_test.go2
-rw-r--r--tests/sharedstorage/sharedstorage_test.go4
6 files changed, 8 insertions, 8 deletions
diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go
index d63625b..c433e92 100644
--- a/tests/cli/cli_test.go
+++ b/tests/cli/cli_test.go
@@ -982,7 +982,7 @@ func TestMountCreat(t *testing.T) {
for i := 0; i < concurrency; i++ {
go func(i int) {
path := fmt.Sprintf("%s/%d", mnt, i)
- fd, err := syscall.Creat(path, 0600)
+ fd, err := syscall.Open(path, syscall.O_CREAT|syscall.O_WRONLY|syscall.O_TRUNC, 0600)
syscall.Close(fd)
if err != nil {
t.Errorf("Creat %q: %v", path, err)
diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go
index 5310003..43019ba 100644
--- a/tests/defaults/main_test.go
+++ b/tests/defaults/main_test.go
@@ -401,7 +401,7 @@ func TestMaxlen(t *testing.T) {
func TestFsync(t *testing.T) {
fileName := test_helpers.DefaultPlainDir + "/" + t.Name() + ".file"
- fileFD, err := syscall.Creat(fileName, 0600)
+ fileFD, err := syscall.Open(fileName, syscall.O_CREAT|syscall.O_WRONLY|syscall.O_TRUNC, 0600)
if err != nil {
t.Fatal(err)
}
@@ -447,7 +447,7 @@ func TestForceOwner(t *testing.T) {
// In the answer to a FUSE CREATE, gocryptfs sends file information including
// the owner. This is cached by the kernel and will be used for the next
// stat() call.
- fd, err := syscall.Creat(foo, 0666)
+ fd, err := syscall.Open(foo, syscall.O_CREAT|syscall.O_WRONLY|syscall.O_EXCL, 0666)
if err != nil {
t.Fatal(err)
}
diff --git a/tests/matrix/concurrency_test.go b/tests/matrix/concurrency_test.go
index d133c45..d824316 100644
--- a/tests/matrix/concurrency_test.go
+++ b/tests/matrix/concurrency_test.go
@@ -144,7 +144,7 @@ func TestInoReuse(t *testing.T) {
wg.Add(1)
go func() {
for i := 0; i < 1000; i++ {
- fd, err := syscall.Creat(fn, 0600)
+ fd, err := syscall.Open(fn, syscall.O_CREAT|syscall.O_WRONLY|syscall.O_TRUNC, 0600)
if err == syscall.EISDIR {
continue
}
diff --git a/tests/plaintextnames/plaintextnames_test.go b/tests/plaintextnames/plaintextnames_test.go
index c6d6145..f2dc7e7 100644
--- a/tests/plaintextnames/plaintextnames_test.go
+++ b/tests/plaintextnames/plaintextnames_test.go
@@ -116,7 +116,7 @@ func TestInoReuseEvil(t *testing.T) {
}
// create a new file that will likely get the same inode number
pPath2 := pPath + "2"
- fd, err := syscall.Creat(pPath2, 0600)
+ fd, err := syscall.Open(pPath2, syscall.O_CREAT|syscall.O_WRONLY|syscall.O_TRUNC, 0600)
if err != nil {
t.Fatal(err)
}
diff --git a/tests/root_test/root_test.go b/tests/root_test/root_test.go
index 3794e69..f0f5a1b 100644
--- a/tests/root_test/root_test.go
+++ b/tests/root_test/root_test.go
@@ -120,7 +120,7 @@ func writeTillFull(t *testing.T, path string) (int, syscall.Errno) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- fd, err := syscall.Creat(path, 0600)
+ fd, err := syscall.Open(path, syscall.O_CREAT|syscall.O_WRONLY|syscall.O_TRUNC, 0600)
if err != nil {
return 0, err.(syscall.Errno)
}
diff --git a/tests/sharedstorage/sharedstorage_test.go b/tests/sharedstorage/sharedstorage_test.go
index a08deed..88f3304 100644
--- a/tests/sharedstorage/sharedstorage_test.go
+++ b/tests/sharedstorage/sharedstorage_test.go
@@ -77,7 +77,7 @@ func TestDirUnlink(t *testing.T) {
if err := unix.Rmdir(tc.mnt2 + "/foo"); err != nil {
t.Fatal(err)
}
- if fd, err := unix.Creat(tc.mnt2+"/foo", 0600); err != nil {
+ if fd, err := unix.Open(tc.mnt2+"/foo", unix.O_CREAT|unix.O_WRONLY|unix.O_TRUNC, 0600); err != nil {
t.Fatal(err)
} else {
unix.Close(fd)
@@ -104,7 +104,7 @@ func TestStaleHardlinks(t *testing.T) {
defer tc.cleanup()
link0 := tc.mnt1 + "/link0"
- if fd, err := unix.Creat(link0, 0600); err != nil {
+ if fd, err := unix.Open(link0, unix.O_CREAT|unix.O_WRONLY|unix.O_TRUNC, 0600); err != nil {
t.Fatal(err)
} else {
unix.Close(fd)