summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/defaults/main_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go
index b356f41..2513860 100644
--- a/tests/defaults/main_test.go
+++ b/tests/defaults/main_test.go
@@ -11,6 +11,7 @@ import (
"runtime"
"strings"
"sync"
+ "syscall"
"testing"
"github.com/rfjakob/gocryptfs/tests/test_helpers"
@@ -394,3 +395,30 @@ func TestMaxlen(t *testing.T) {
t.Errorf("wrong output: %s", string(out))
}
}
+
+func TestFsync(t *testing.T) {
+ fileName := test_helpers.DefaultPlainDir + "/" + t.Name() + ".file"
+ fileFD, err := syscall.Creat(fileName, 0600)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer syscall.Close(fileFD)
+ dirName := test_helpers.DefaultPlainDir + "/" + t.Name() + ".dir"
+ if err := os.Mkdir(dirName, 0700); err != nil {
+ t.Fatal(err)
+ }
+ dirFD, err := syscall.Open(dirName, syscall.O_RDONLY, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer syscall.Close(dirFD)
+
+ err = syscall.Fsync(dirFD)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = syscall.Fsync(fileFD)
+ if err != nil {
+ t.Fatal(err)
+ }
+}