From 04241455a2401a60451eb84cf7e3f8fe276c52a5 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 11 Oct 2018 20:43:28 +0200 Subject: tests: add idle timeout test Mount with idle timeout 10ms and check that the process exits by itself within 5 seconds. --- tests/cli/cli_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/cli') 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) + } +} -- cgit v1.2.3