aboutsummaryrefslogtreecommitdiff
path: root/tests/cli
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-09-08 16:16:18 +0200
committerJakob Unterwurzacher2019-09-08 16:16:18 +0200
commitce13851bbfceb02da0b36e743090c5fe54469b33 (patch)
treeeb812467babf6290e3e0470615dcdd0c76020589 /tests/cli
parentea634090dce2f9a7fe62bae397b92d5940a0be0e (diff)
tests: add TestNotIdle
Mount with idle timeout of 100ms read something every 10ms. The fs should NOT get unmounted. Regression test for https://github.com/rfjakob/gocryptfs/issues/421
Diffstat (limited to 'tests/cli')
-rw-r--r--tests/cli/cli_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go
index da9d508..0461d3c 100644
--- a/tests/cli/cli_test.go
+++ b/tests/cli/cli_test.go
@@ -568,3 +568,44 @@ func TestIdle(t *testing.T) {
t.Error(err)
}
}
+
+// Mount with idle timeout of 100ms read something every 10ms. The fs should
+// NOT get unmounted. Regression test for https://github.com/rfjakob/gocryptfs/issues/421
+func TestNotIdle(t *testing.T) {
+ dir := test_helpers.InitFS(t)
+ mnt := dir + ".mnt"
+ err := os.Mkdir(mnt, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = test_helpers.Mount(dir, mnt, false, "-extpass", "echo test", "-i=100ms")
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = ioutil.WriteFile(mnt+"/foo", []byte("foo"), 0600)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // Read every 10 milliseconds for a total of 1 second
+ for i := 1; i < 100; i++ {
+ _, err = ioutil.ReadFile(mnt + "/foo")
+ if err != nil {
+ t.Fatalf("iteration %d failed: %v", i, err)
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
+ // Keep a file handle open for 1 second
+ fd, err := os.Open(mnt + "/foo")
+ if err != nil {
+ t.Fatal(err)
+ }
+ time.Sleep(1 * time.Second)
+ buf := make([]byte, 100)
+ _, err = fd.Read(buf)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fd.Close()
+ // All good.
+ test_helpers.UnmountPanic(mnt)
+}