diff options
author | Jakob Unterwurzacher | 2018-10-11 20:43:28 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2018-10-11 20:43:28 +0200 |
commit | 04241455a2401a60451eb84cf7e3f8fe276c52a5 (patch) | |
tree | 3c1abea64d33dc5801a08c09b42be3404add1dbb /tests/cli/cli_test.go | |
parent | 87d3ed9187cb9caccaa8df0769d4cb722cc5bd00 (diff) |
tests: add idle timeout test
Mount with idle timeout 10ms and check that the process exits by itself
within 5 seconds.
Diffstat (limited to 'tests/cli/cli_test.go')
-rw-r--r-- | tests/cli/cli_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index 51b52c6..fa0b576 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -535,3 +535,30 @@ func TestComma(t *testing.T) { } test_helpers.UnmountPanic(mnt) } + +// Mount with idle timeout 10ms and check that the process exits by itself +// within 5 seconds. +func TestIdle(t *testing.T) { + dir := test_helpers.InitFS(t) + mnt := dir + ".mnt" + err := os.Mkdir(mnt, 0700) + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(test_helpers.GocryptfsBinary, + "-q", "-nosyslog", "-fg", "-extpass", "echo test", "-i", "10ms", dir, mnt) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Start(); err != nil { + t.Fatal(err) + } + timer := time.AfterFunc(5*time.Second, func() { + t.Error("timeout waiting for umount") + cmd.Process.Kill() + }) + err = cmd.Wait() + timer.Stop() + if err != nil { + t.Error(err) + } +} |