@@ -8,6 +8,12 @@ management. In some cases optional features are turned on by mkfs and the
8
8
filesystem image could be mounted, such tests might fail if there's lack of
9
9
support.
10
10
11
+ The testsuite follows the principles:
12
+
13
+ - gather all output to logs
14
+ - stop on first failure (do not clean up until the problem is investigated)
15
+ - detect available capabilities in the system, skip if missing
16
+
11
17
## Quick start
12
18
13
19
Run the tests from the top directory:
@@ -199,7 +205,7 @@ command `losetup` and eventually delete all existing loop devices with `losetup
199
205
### Prototyping tests, quick tests
200
206
201
207
There's a script ` test-console.sh ` that will run shell commands in a loop and
202
- logs the output with the testing environment set up. It sources the common
208
+ log the output with the testing environment set up. It sources the common
203
209
helper scripts so the shell functions are available.
204
210
205
211
### Runtime dependencies
@@ -213,7 +219,8 @@ specific tests need the following packages installed: `acl`, `attr`,
213
219
214
220
1 . Pick the category for the new test or fallback to ` misc-tests ` if not sure. For
215
221
an easy start copy an existing ` test.sh ` script from some test that might be
216
- close to the purpose of your new test. The environment setup includes the
222
+ close to the purpose of your new test, or use one of the templates in the
223
+ [ tests/template/] ( template/ ) directory. The environment setup includes the
217
224
common scripts and/or prepares the test devices. Other scripts contain examples
218
225
how to do mkfs, mount, unmount, check, loop device management etc.
219
226
@@ -229,22 +236,23 @@ infrastructure.
229
236
230
237
5 . ** Test your test.** Use the ` TEST ` variable to jump right to your test:
231
238
``` shell
232
- $ make TEST=012\* tests-misc # from top directory
233
- $ TEST=012\* ./misc-tests.sh # from tests/
239
+ $ make TEST=012\* tests-misc # from the top or tests/ directory
240
+ $ TEST=012\* ./misc-tests.sh # alternatively from tests/
234
241
```
235
242
236
243
6 . The commit changelog should reference a commit that either introduced or
237
- fixed the bug (or both). Subject line of the shall mention the name of the
238
- new directory for ease of search, e.g. ` btrfs-progs: tests: add 012-subvolume-sync-must-wait `
244
+ fixed the bug (or both). Subject line of the could mention the name of the
245
+ new directory for ease of search (e.g. ` btrfs-progs: tests: add 012-subvolume-sync-must-wait ` )
246
+ or a brief description of the test case (e.g. ` btrfs-progs: tests: add case for waiting on subvolume sync after deletion ` )
239
247
240
- 7 . A commit that fixes a bug should be applied before the test that verifies
248
+ 7 . A commit that fixes a bug should be applied * before* the test that verifies
241
249
the fix. This is to keep the git history bisectable.
242
250
243
251
244
252
### Test images
245
253
246
254
Most tests should be able to create the test images from scratch, using regular
247
- commands and file operation . The commands also document the test case and use
255
+ commands and file operations . The commands also document the test case and use
248
256
the test code and kernel of the environment.
249
257
250
258
In other cases, a pre-created image may be the right way if the above does not
@@ -295,7 +303,8 @@ There are some utilities that are not distributed but are necessary for the
295
303
tests. They are in the top level directory of the testsuite and their path
296
304
cannot be set.
297
305
298
- The tests assume write access to their directories.
306
+ The tests assume write access to their directories and an existing ` /tmp `
307
+ directory.
299
308
300
309
301
310
# Coding style, best practices
@@ -305,9 +314,10 @@ The tests assume write access to their directories.
305
314
* quote all variables by default, any path, even the TOP could need that, and
306
315
we use it everywhere
307
316
* even if the variable is safe, use quotes for consistency and to ease
308
- reading the code
317
+ reading the code (syntax highlighting in editors)
309
318
* there are exceptions:
310
319
* ` $SUDO_HELPER ` as it might be intentionally unset
320
+ * conditionally set options that are stored in a variable
311
321
* use ` #!/bin/bash ` explicitly
312
322
* check for all external dependencies (` check_global_prereq ` )
313
323
* check for internal dependencies (` check_prereq ` ), though the basic set is
0 commit comments