Commit Graph

282 Commits

Author SHA1 Message Date
Jakob Unterwurzacher 65bc006a78 stress_tests: use /var/tmp by default
There is a good chance that /tmp is tmpfs, and we want to
run our tests on a real filesystem.
2019-10-06 22:34:19 +02: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 ce13851bbf 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
2019-09-08 16:16:18 +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 7eba4f0788 tests: matrix: test -serialize_reads
Test if https://github.com/rfjakob/gocryptfs/pull/413 works
as intended.
2019-09-01 12:51:42 +02:00
Jakob Unterwurzacher 991adfc934 -passwd now takes a passed -scryptn flag into account
https://github.com/rfjakob/gocryptfs/issues/400
2019-05-13 23:01:44 +02:00
Jakob Unterwurzacher 8d083e61f4 tests: root_test: also test file creation 2019-05-01 18:30:16 +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 96935e16b9 tests: add root_tests (tests that must run as root)
First test is a reproducer for
https://github.com/rfjakob/gocryptfs/issues/394 "Group permissions: No write access"
2019-05-01 13:12:44 +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
leilaes cc0a603ef8 Add CodeLingo Tenet to fix missing close file 2019-04-10 13:33:58 +02:00
Jakob Unterwurzacher 24036ab89f tests: speed up new tests a little
Before: ok  	github.com/rfjakob/gocryptfs/tests/matrix	18.560s
After:  ok  	github.com/rfjakob/gocryptfs/tests/matrix	13.425s
2019-04-08 20:34:24 +02:00
Jakob Unterwurzacher d851cf8055 tests: add TestConcurrentReadCreate, move to new file
https://github.com/rfjakob/gocryptfs/issues/363
2019-04-08 20:27:13 +02:00
Jakob Unterwurzacher d22ccf68b2 tests: add TestConcurrentReadWrite
Another attempt to find out what is going on behind
https://github.com/rfjakob/gocryptfs/issues/363
2019-04-08 20:27:13 +02:00
Jakob Unterwurzacher 311c34af4b tests: add additional TestWrite10Tight test
Try to find out what goes wrong in
https://github.com/rfjakob/gocryptfs/issues/363
2019-04-08 20:27:13 +02:00
Jakob Unterwurzacher fe06e9f456 readpassword: delete CheckTrailingGarbage
CheckTrailingGarbage was called even when "-passfile" was
used, which is stupid, and causes false positives:

https://github.com/rfjakob/gocryptfs/issues/391
(false error "Received trailing garbage after the password"
when using -passfile in .bash_profile)

Instead of trying to improve the logic to handle that case
and make everything even more complicated, delete the function.

It is unclear if actually helps in some cases, and it definitely
harms as shown by the above bug report.
2019-04-08 20:18:45 +02:00
Jakob Unterwurzacher 8f2723b387 Allow "nofail" for /etc/fstab use 2019-03-31 14:33:02 +02:00
Jakob Unterwurzacher ec17445b99 forward mode: create gocryptfs.diriv files with 0440 permissions
Makes it easier to share an encrypted folder via a network drive.

https://github.com/rfjakob/gocryptfs/issues/387
2019-03-30 20:06:40 +01:00
Eduardo M KALINOWSKI 3bc100aeb3 reverse mode: support wildcard exclude (--exclude-wildcard)
This adds support for gitignore-like wildcards and exclude patters in
reverse mode. It (somewhat) fixes #273: no regexp support, but the
syntax should be powerful enough to satisfy most needs.

Also, since adding a lot of --exclude options can be tedious, it adds
the --exclude-from option to read patterns from a file (or files).
2019-03-26 20:56:37 +01:00
Jakob Unterwurzacher cd7a686211 tests: fix data race in TestDirIVRace
Ironically, the test for DirIV races had a data race itself
by writing to a bool without taking a lock.

Found by running "./test.bash -race":

WARNING: DATA RACE
Write at 0x00c00001dea5 by goroutine 22:
  github.com/rfjakob/gocryptfs/tests/defaults.TestDirIVRace.func1()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/diriv_test.go:39 +0x38
  github.com/rfjakob/gocryptfs/tests/defaults.TestDirIVRace()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/diriv_test.go:73 +0x65c
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:865 +0x163

Previous read at 0x00c00001dea5 by goroutine 23:
  github.com/rfjakob/gocryptfs/tests/defaults.TestDirIVRace.func2()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/diriv_test.go:51 +0x8b

Goroutine 22 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:916 +0x699
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1072 +0x2eb
  github.com/rfjakob/gocryptfs/tests/defaults.TestMain()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/main_test.go:21 +0xe1
  main.main()
      _testmain.go:76 +0x222

Goroutine 23 (running) created at:
  github.com/rfjakob/gocryptfs/tests/defaults.TestDirIVRace()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/diriv_test.go:43 +0x48d
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:865 +0x163
==================
--- FAIL: TestDirIVRace (0.00s)
    testing.go:809: race detected during execution of test
FAIL
2019-03-03 14:09:33 +01:00
Jakob Unterwurzacher 173218895c tests: fix compile error in matrix_test.go
Error was:

tests/matrix/matrix_test.go:101:9: no new variables on left side of :=
2019-02-17 17:25:41 +01:00
Jakob Unterwurzacher 179471b648 ParseHeader: print hexdump on error
Should help debugging https://github.com/rfjakob/gocryptfs/issues/363
2019-02-17 17:13:20 +01:00
Jakob Unterwurzacher 19cb6d046a nametransform: reject names longer than 255 chars
Looks like we allowed creating longer names by accident.
Fix that, and add a test that verifies it.
2019-02-17 17:05:05 +01:00
Jakob Unterwurzacher 26286a5f8c test: len2elen.sh: fix first line output 2019-02-17 16:06:05 +01:00
Jakob Unterwurzacher fa98664d8a tests: add len2elen.sh
Check plaintext file name length -> encrypted file name length relation

Example output:

0 22
2 22
3 22
4 22
5 22
6 22
7 22
8 22
9 22
10 22
11 22
12 22
13 22
14 22
15 22
16 43
17 43
18 43
19 43
20 43
21 43
22 43
23 43
24 43
25 43
26 43
27 43
28 43
29 43
30 43
31 43
32 64
33 64
34 64
35 64
36 64
37 64
38 64
39 64
40 64
41 64
42 64
43 64
44 64
45 64
46 64
47 64
48 86
49 86
50 86
51 86
52 86
53 86
54 86
55 86
56 86
57 86
58 86
59 86
60 86
61 86
62 86
63 86
64 107
65 107
66 107
67 107
68 107
69 107
70 107
71 107
72 107
73 107
74 107
75 107
76 107
77 107
78 107
79 107
80 128
81 128
82 128
83 128
84 128
85 128
86 128
87 128
88 128
89 128
90 128
91 128
92 128
93 128
94 128
95 128
96 150
97 150
98 150
99 150
100 150
101 150
102 150
103 150
104 150
105 150
106 150
107 150
108 150
109 150
110 150
111 150
112 171
113 171
114 171
115 171
116 171
117 171
118 171
119 171
120 171
121 171
122 171
123 171
124 171
125 171
126 171
127 171
128 192
129 192
130 192
131 192
132 192
133 192
134 192
135 192
136 192
137 192
138 192
139 192
140 192
141 192
142 192
143 192
144 214
145 214
146 214
147 214
148 214
149 214
150 214
151 214
152 214
153 214
154 214
155 214
156 214
157 214
158 214
159 214
160 235
161 235
162 235
163 235
164 235
165 235
166 235
167 235
168 235
169 235
170 235
171 235
172 235
173 235
174 235
175 235
176 67
177 67
178 67
179 67
180 67
181 67
182 67
183 67
184 67
185 67
186 67
187 67
188 67
189 67
190 67
191 67
192 67
193 67
194 67
195 67
196 67
197 67
198 67
199 67
200 67
201 67
202 67
203 67
204 67
205 67
206 67
207 67
208 67
209 67
210 67
211 67
212 67
213 67
214 67
215 67
216 67
217 67
218 67
219 67
220 67
221 67
222 67
223 67
224 67
225 67
226 67
227 67
228 67
229 67
230 67
231 67
232 67
233 67
234 67
235 67
236 67
237 67
238 67
239 67
240 67
241 67
242 67
243 67
244 67
245 67
246 67
247 67
248 67
249 67
250 67
251 67
252 67
253 67
254 67
255 67
2019-02-17 16:03:43 +01:00
Jakob Unterwurzacher 5826ff8c9c tests: parallel_cp.sh: automount fs
Teach the script to automatically mount and unmount.
2019-02-17 16:02:30 +01:00
Jakob Unterwurzacher b86cc3304f tests: simplify parallel_cp.sh
Get rid of one extra directory level. Hopefully makes it
easier to follow the debug logs.
2019-01-23 22:14:31 +01:00
Jakob Unterwurzacher da3ba5e7f5 tests: darwin: ignore error in TestMvWarningSymlink
https://github.com/rfjakob/gocryptfs/issues/349
2019-01-20 17:20:30 +01: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
Jakob Unterwurzacher fab585ec01 tests: matrix: split out directory tests into their own file
matrix_test.go is already too big.
2019-01-20 13:41:20 +01:00
Jakob Unterwurzacher 3d6b2685fb Revert "syscallcompat: drop Faccessat AT_SYMLINK_NOFOLLOW helper"
Breaks mounting on MacOS: unix.Faccessat on Darwin does NOT (yet)
support AT_SYMLINK_NOFOLLOW. See d44fe89ba4 .

This reverts commit 0805a63df1.
2019-01-20 13:10:59 +01:00
Jakob Unterwurzacher 0805a63df1 syscallcompat: drop Faccessat AT_SYMLINK_NOFOLLOW helper
unix.Faccessat has added support for AT_SYMLINK_NOFOLLOW in July 2018,
bd9dbc187b (diff-341484dbbe3180cd7a31ef2ad2d679b6)
which means we no longer need our own helper.

Closes https://github.com/rfjakob/gocryptfs/issues/347
2019-01-20 12:59: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
Jakob Unterwurzacher 5c8e7feabd tests: check that fallocate does not over-allocate space
We currently allocate 18 bytes too much:
https://github.com/rfjakob/gocryptfs/issues/311
2019-01-06 20:56:53 +01:00
Jakob Unterwurzacher c83aa417e4 tests: move fallocate tests to its own file
matrix_test.go is already too big.
2019-01-06 20:31:41 +01:00
Jakob Unterwurzacher db425cab9e tests: TestFallocate: comment what "d" and "h" means
Document what "d" and "h" means in the fancy ASCII diagrams.
https://github.com/rfjakob/gocryptfs/pull/326
2019-01-06 12:49:27 +01:00
Jakob Unterwurzacher fb705f9978 tests: add parallel_cp stress test
Modeled after xfstests generic/273
https://github.com/rfjakob/gocryptfs/issues/322
2019-01-05 18:20:04 +01:00
Sebastian Lackner 5055f39bd5 fusefrontend: Allow to set/remove xattr on directory without read permission.
Setting/removing extended attributes on directories was partially fixed with
commit eff35e60b6. However, on most file systems
it is also possible to do these operations without read access (see tests).

Since we cannot open a write-access fd to a directory, we have to use the
/proc/self/fd trick (already used for ListXAttr) for the other operations aswell.
For simplicity, let's separate the Linux and Darwin code again (basically revert
commit f320b76fd1), and always use the
/proc/self/fd trick on Linux. On Darwin we use the best-effort approach with
openBackingFile() as a fallback.

More discussion about the available options is available in
https://github.com/rfjakob/gocryptfs/issues/308.
2019-01-05 12:34:40 +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 eff35e60b6 fusefrontend: fix setting xattrs on directories
Directories cannot be opened read-write. Retry with RDONLY.
2019-01-04 22:22:24 +01:00
Jakob Unterwurzacher 58f62ada46 tests: reverse: verify that longname .name files are exluded as well
Currently fails, will be fixed in the next commit.

https://github.com/rfjakob/gocryptfs/issues/286
2019-01-04 17:57:57 +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
Jakob Unterwurzacher 1c9fb707fe tests: overengineer extractloop_plot_csv.m a little
Plot iteration time on second y axis, adjust line styles
2019-01-03 18:24:14 +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 71d07b7c73 tests: extractloop: renice to level 19
Run at low priority to not annoy the user too much.
2019-01-03 16:14:05 +01:00