File: 0001-tests-add-TestNotIdle.patch

package info (click to toggle)
gocryptfs 2.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,132 kB
  • sloc: sh: 1,091; ansic: 208; makefile: 88
file content (58 lines) | stat: -rw-r--r-- 1,808 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From ce13851bbfceb02da0b36e743090c5fe54469b33 Mon Sep 17 00:00:00 2001
From: Jakob Unterwurzacher <jakobunt@gmail.com>
Date: Sun, 8 Sep 2019 16:16:18 +0200
Subject: [PATCH] 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
---
 tests/cli/cli_test.go |   41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

--- a/tests/cli/cli_test.go
+++ b/tests/cli/cli_test.go
@@ -1093,3 +1093,44 @@ func TestOrphanedSocket(t *testing.T) {
 	test_helpers.MountOrFatal(t, cDir, mnt, "-extpass", "echo test", "-wpanic=false", "-ctlsock", ctlSock)
 	test_helpers.UnmountPanic(mnt)
 }
+
+// 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)
+}