From 952d45ce84f63de963a1727e439e95883f9e65c1 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 12 Mar 2021 19:25:25 +0100 Subject: tests: add TestDiskFull Also fix incomplete uid restoration in TestSupplementaryGroups and replace syscall.Setregid and friends with unix.Setregid and friends. This test is added to check if have problems handling a full disk. The ticket https://github.com/rfjakob/gocryptfs/issues/550 states that the full disk was not where the backing gocryptfs filesystem was, but this has no effect on gocryptfs, so we test the harder case. --- tests/cli/cli_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/cli') diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index 23cea05..9d25062 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -9,6 +9,7 @@ import ( "os/exec" "strconv" "strings" + "sync" "syscall" "testing" "time" @@ -869,3 +870,35 @@ func TestSharedstorage(t *testing.T) { t.Fatal(st2.Size) } } + +// Test that the filesystem is immediately ready for Creat() after mount returns +func TestMountCreat(t *testing.T) { + const concurrency = 2 + const repeat = 2 + + dir := test_helpers.InitFS(t) + mnt := dir + ".mnt" + err := os.Mkdir(mnt, 0700) + if err != nil { + t.Fatal(err) + } + + for j := 0; j < repeat; j++ { + test_helpers.MountOrFatal(t, dir, mnt, "-extpass=echo test") + var wg sync.WaitGroup + wg.Add(concurrency) + for i := 0; i < concurrency; i++ { + go func(i int) { + path := fmt.Sprintf("%s/%d", mnt, i) + fd, err := syscall.Creat(path, 0600) + syscall.Close(fd) + if err != nil { + t.Errorf("Creat %q: %v", path, err) + } + wg.Done() + }(i) + } + wg.Wait() + test_helpers.UnmountPanic(mnt) + } +} -- cgit v1.2.3