Commit Graph

73 Commits

Author SHA1 Message Date
Jakob Unterwurzacher
f8ad2ac3e2 dircache: increase cache size & lifetime
Looking at the dircache debug output, we see
that a "git status" workload has a very bad
cache hit rate because the entries expire or
get evicted before they can be reused.

Increase both cache size and lifetime for
a 4x speedup:

Before: 75s
After:  17s

https://github.com/rfjakob/gocryptfs/issues/410
2020-05-17 21:37:36 +02:00
Jakob Unterwurzacher
ead7008a08 Fix spelling mistakes found by misspell
https://github.com/client9/misspell
2020-05-10 00:25:49 +02:00
Jakob Unterwurzacher
a9895b3487 gocryptfs-xray: add -0 flag, add tests
The -0 flags works like xargs -0.
2020-05-10 00:04:14 +02:00
Jakob Unterwurzacher
171b1eac91 test_helpers: use new ctlsock.CtlSock API 2020-05-09 19:09:33 +02:00
Jakob Unterwurzacher
f0184804f4 test_helper: kill lsof after 1 second
lsof may get stuck when gocryptfs itself is stuck.
2020-05-09 19:03:16 +02:00
Jakob Unterwurzacher
16221facb9 ctlsock: create exported ctlsock client library
The former interal ctlsock server package is renamed
to ctlsocksrv.
2020-05-09 17:36:41 +02:00
Jakob Unterwurzacher
c19baa10f8 tests: use t.Name()
We did not use t.Name() as it was not available
before Go 1.8. Now the oldest Go version we support is
Go 1.11, so we can use it.
2020-05-09 15:42:57 +02:00
Jakob Unterwurzacher
31ff557f85 tests: also check inode number in VerifySize
Check Stat() vs Fstat() result. Not very useful
at the moment as the kernel never seems to call Fstat().
2019-11-16 21:25:14 +01:00
Jakob Unterwurzacher
8c44294087 tests: use /var/tmp by default
On Fedora, /tmp is tmpfs, which behaves differently than ext4
(inode numbers are never reused, for example).

Use /var/tmp, which is ext4 on Fedora, to get a more realistic
test environment.

This also allows us to drop the xattr workaround.
2019-10-06 21:53:20 +02:00
Jakob Unterwurzacher
1fb18f4a9e tests: filter leaked fds by prefix
When running

  $ go test ./tests/matrix/

in isolation, it failed like this:

  fd leak? before, after:
  [0r=/dev/null 3w=/dev/null 5r=/proc/8078/fd (hidden:4)]
  [0r=/dev/null 3w=/dev/null 5w=/tmp/go-build366655199/b001/testlog.txt 7r=/proc/8078/fd (hidden:4)]

Filter by prefix to get rid of this spurious test failure.
2019-10-06 19:37:51 +02:00
Jakob Unterwurzacher
d361f6e35b tests: clarify which process seems to be leaking fds
The tests check if they leak fds themselves, but we also
check if gocryptfs leaks fds. Clarify what is what in the
error message.
2019-10-06 18:48:09 +02:00
Jakob Unterwurzacher
ea634090dc test_helpers: ListFds: handle an exited process gracefully
This used to dump a backtrace to the console which obscured what
is going on.
2019-09-08 16:15:35 +02:00
Jakob Unterwurzacher
e22c8ea0bd tests: fix root_test permission issues
The parent directories need execute all permissions.
2019-05-01 18:29:06 +02:00
Jakob Unterwurzacher
3ac9872230 tests: split testParentDir by UID
When we run tests as root, they will leave root-owned files
in testParentDir, which causes trouble when we run tests as
a normal user later on. Split by UID.
2019-05-01 13:12:44 +02:00
Jakob Unterwurzacher
41dfbe67f8 test_helpers: better function comments for InitFS and Mount
It's confusing that you must pass "-extpass" for Mount but not
for InitFS. Note that in the comment.
2019-05-01 13:12:44 +02:00
Jakob Unterwurzacher
ec4c9f2adb tests: check that we can delete directories with all permission
Regression test for https://github.com/rfjakob/gocryptfs/issues/354
2019-01-20 14:32:59 +01:00
Sebastian Lackner
1d2ce9c213 tests: Increase timeout in Mount() function.
This avoids sporadic test failures on macOS.
2019-01-15 22:08:20 +01:00
Jakob Unterwurzacher
20140e24ed tests: reduce noise on MacOS
This should get rid of

    Openat: O_NOFOLLOW missing: flags = 0x0
    Fchmodat: adding missing AT_SYMLINK_NOFOLLOW flag
    sys_common_test.go:203: chmod on symlink should have failed, but did not. New mode=0333
    UnmountErr: "[...]/057376762.mnt" was not found in MountInfo, cannot check for FD leak

and add some context to

    --- FAIL: TestUtimesNano (0.00s)
    matrix_test.go:628: no such file or directory

See https://github.com/rfjakob/gocryptfs/pull/343#issuecomment-453888006
for full test output
2019-01-14 22:11:15 +01:00
Sebastian Lackner
f17721c364 A few more spelling fixes. 2019-01-05 12:27:55 +01:00
Jakob Unterwurzacher
65eded4a22 tests: bump maxCacheFds to 3
As the dirCache now has 3 entries, the tests should accept
up to 3 extra fds without declaring an fd leak.
2019-01-04 23:50:01 +01:00
Jakob Unterwurzacher
a2f83acc30 tests: fix VerifyExistence() helper, it missed unstat()able files
VerifyExistence missed unstat()able files in the directory listing
because ioutil.ReadDir() filtered them out.

https://github.com/rfjakob/gocryptfs/issues/285
2019-01-04 17:36:06 +01:00
Sebastian Lackner
a1ba4b6576 Omit syscall.O_RDONLY flag when passing O_PATH.
When O_PATH is specified in flags, flag bits other than O_CLOEXEC, O_DIRECTORY,
and O_NOFOLLOW are ignored.
2019-01-03 18:24:05 +01:00
Jakob Unterwurzacher
bb9884549b tests: allow one extra fd in fd leak detector (dirCache)
The gocryptfs process may keep one fd open for up to one second
in the dirCache.
2019-01-03 15:38:51 +01:00
Jakob Unterwurzacher
f6dad8d0fa nametransform: simplify WriteDirIV to WriteDirIVAt
Un-spaghettify the function and let the callers open
the directory.
2019-01-03 15:31:13 +01:00
Jakob Unterwurzacher
59f1300591 tests: retry longer when we see a fd leak
Hopefully gets rid of the false positives on travis.
2019-01-02 21:03:26 +01:00
Jakob Unterwurzacher
772afa93f9 tests: add fd leak retry logic to UnmountErr, really return error
Give the gocryptfs process one extra millisecond to close
files. Allows us to drop several other sleeps.

UnmountErr now really returns an error when it detects an fd leak
instead of just printing a message.
2019-01-02 01:09:09 +01:00
Jakob Unterwurzacher
d5a74d2a3e tests: ListFds(): filter out pipe and eventpoll fds
These are created on demand by the Go runtime and are usually
not interesting.
2019-01-02 00:09:17 +01:00
Jakob Unterwurzacher
b1819143c5 tests: make MountInfo field accessible
Tests outside the test_helpers package may want to look
at this.
2019-01-02 00:09:17 +01:00
Jakob Unterwurzacher
035834dd51 tests: ListFds: show r/w status
Also, drop entries that disappear while we stat them.
2019-01-01 22:27:40 +01:00
Jakob Unterwurzacher
e276e255dc tests: split mount_unmount.go from helpers.go
With the FD leak logic, the mount/unmount functions have
become complex enough to give them their own file.
2019-01-01 22:27:10 +01:00
Jakob Unterwurzacher
10de105c13 tests: detect fd leaks on unmount
For now, this only prints a message but does not fail the tests.
2019-01-01 22:01:49 +01:00
Jakob Unterwurzacher
887d5aa8e7 tests: teach ListFds() to check other processes 2019-01-01 20:05:38 +01:00
Jakob Unterwurzacher
817c485bb7 tests: save gocryptfs process id in test_helpers.MountPID
This will allow to tests to monitor fd usage and maybe other things.
2019-01-01 19:34:12 +01:00
Jakob Unterwurzacher
5a1ebdb4f7 tests: respect TMPDIR if set
Setting TMPDIR now allows to run the tests against
a directory of your choice, making it easier to test
different filesystems.
2018-10-10 22:24:20 +02:00
Jakob Unterwurzacher
c270b21efc fusefrontend: get rid of os.File* wrapping
Directly use int file descriptors for the dirfd
and get rid of one level of indirection.
2018-09-23 12:17:26 +02:00
Jakob Unterwurzacher
06f1ea951b tests: VerifyExistence: panic on inconsistent results
In the past we did not check whether all methods of checking
the file return the same result. We should.
2018-08-11 22:37:22 +02:00
Jakob Unterwurzacher
53d6a9999d main: accept -dev, -nodev, -suid, -nosuid, -exec, -noexec
When mounted via /etc/fstab like this,

  /a /b fuse.gocryptfs default 0 0

we always get extra options passed. As reported by @mahkoh
at https://github.com/rfjakob/gocryptfs/pull/233 :

  mount passes `-o noexec` if `-o user` is set and `-o exec` is not set.
  If both `-o user` and `-o exec` are set, it passes `-o exec`.

Make these options work, and in addtion, also make -suid and -rw
work the same way.

Reported-by: @mahkoh
2018-06-07 22:50:30 +02:00
Jakob Unterwurzacher
996d2f141b tests: helpers: fix a few error reports
These were using stale err values.
2018-04-27 20:19:51 +02:00
Jakob Unterwurzacher
bcc8378a2c Fix the easy golint warnings
Reported by https://goreportcard.com/report/github.com/rfjakob/gocryptfs
2018-04-08 20:26:25 +02:00
Jakob Unterwurzacher
cab0cda449 tests: retry umount
Gnome may still have files open causing spurious test
failures.
2018-04-08 20:09:05 +02:00
Jakob Unterwurzacher
22031d7e53 tests: matrix: check for fd leaks
And fix two in test_helpers.Mount().

Leftover fds can cause an unmount failure like this later:
fusermount: failed to unmount /tmp/gocryptfs-test-parent/873632270/default-plain: Device or resource busy
so try to catch them early.
2018-04-07 15:24:00 +02:00
Jakob Unterwurzacher
f28d85fad5 fsck: add initial implementation
Most corruption cases except xattr should be covered.
With test filesystem.

The output is still pretty ugly. xattr support will
be added in the next commits.
2018-04-02 16:38:18 +02:00
Jakob Unterwurzacher
f20974c4da test_helpers: add SwitchTestParentDir
SwitchTestParentDir changes testParentDir. This is used when you want
to perform tests on a special filesystem. For example, the xattr tests
cannot run on tmpfs and use /var/tmp instead of /tmp.
2018-03-24 21:40:11 +01:00
Jakob Unterwurzacher
98f735ff6e tests: drop "-z" from fusermount to catch forgotten fds
macos does not have lazy unmount, so let's not use it
on linux either.
If the unmount fails, run "lsof" to find the open file.

Also fix the first bug we found this way.
2018-03-06 21:28:09 +01:00
Jakob Unterwurzacher
35192abb57 test_helpers: add missing newline 2018-03-05 23:06:27 +01:00
Jakob Unterwurzacher
48d5f10c79 test_helpers: use an intermediate pipe for subprocess stdout
To Go test logic waits for stderr and stdout to close, so
when we share it with a subprocess, it will wait for it to
exit as well.

We don't want the tests to hang when the unmount fails.

Seen on MacOS as reported at
https://github.com/rfjakob/gocryptfs/issues/213
2018-02-28 20:03:54 +01:00
Jakob Unterwurzacher
6bd2da89d3 tets_helpers: handle t=nil in InitFS
The reverse tests call InitFS with t=nil. By
calling panic we get a better error message instead
of a generic nil pointer dereference.
2017-12-06 23:03:37 +01:00
Sebastian Lackner
614745ee57 fusefrontend: allow_other: close race between mkdir and chown
Fixes the same problem as described in 72b975867a,
except for directories instead of device nodes.
2017-11-29 13:28:04 +01:00
Jakob Unterwurzacher
ad7942f434 fusefrontend: implement path decryption via ctlsock
Closes https://github.com/rfjakob/gocryptfs/issues/84 .
2017-05-07 21:01:39 +02:00
Jakob Unterwurzacher
68387b470c Fix typos found by Misspell
Misspell Finds commonly misspelled English words
gocryptfs/internal/configfile/scrypt.go
Line 41: warning: "paramter" is a misspelling of "parameter" (misspell)
gocryptfs/internal/ctlsock/ctlsock_serve.go
Line 1: warning: "implementes" is a misspelling of "implements" (misspell)
gocryptfs/tests/test_helpers/helpers.go
Line 27: warning: "compatability" is a misspelling of "compatibility" (misspell)
2017-05-07 12:22:15 +02:00