3 Run the tests from the top directory:
11 or selectively from the `tests/` directory:
18 The verbose output of the tests is logged into a file named after the test
19 category, eg. `fsck-tests-results.txt`.
23 The test are prefixed by a number for ordering and uniqueness. To run a
30 where `MASK` is a glob expression that will execute only tests
31 that match the MASK. Here the test number comes handy:
34 $ make TEST=001\* test-fsck
35 $ TEST=001\* ./fsck-tests.sh
38 will run the first test in fsck-tests subdirectory.
45 * tests targeted at bugs that are fixable by fsck
47 *tests/convert-tests/:*
49 * coverage tests of ext2/3/4 and btrfs-convert options
53 * collection of fuzzed or crafted images
54 * tests that are supposed to run various utilities on the images and not
59 * tests for command line interface, option coverage, weird optin combinations that should not work
60 * not necessary to do any functional testing, could be rather lightweight
61 * functional tests should go to to other test dirs
62 * the driver script will only execute `./test.sh` in the test directory
66 * anything that does not fit to the above, the test driver script will only
67 execute `./test.sh` in the test directory
75 * default testing image, the file is never deleted by the scripts but
76 truncated to 0 bytes, so it keeps it's permissions. It's eg. possible to
77 host it on NFS, make it `chmod a+w` for root.
80 ## Other tuning, environment variables
84 It's possible to wrap the tested commands to utilities that might do more
85 checking or catch failures at runtime. This can be done by setting the
86 `INSTRUMENT` environment variable:
89 INSTRUMENT=valgrind ./fuzz-tests.sh # in tests/
90 make INSTRUMENT=valgrind test-fuzz # in the top directory
93 The variable is prepended to the command *unquoted*, all sorts of shell tricks
96 Note: instrumentation is not applied to privileged commands (anything that uses
101 Setting the variable `TEST_LOG=tty` will print all commands executed by some of
102 the wrappers (`run_check` etc), other commands are silent.
106 Some commands require root privileges (to mount/umount, access loop devices).
107 It is assumed that `sudo` will work in some way (no password, password asked
108 and cached). Note that instrumentation is not applied in this case, for safety
109 reasons. You need to modify the test script instead.
113 The tests are supposed to cleanup after themselves if they pass. In case of
114 failure, the rest of the tests are skipped and intermediate files, mounts and
115 loop devices are kept. This should help to investigate the test failure but at
116 least the mounts and loop devices need to be cleaned before the next run.
118 This is partially done by the script `clean-tests.sh`, you may want to check
119 the loop devices as they are managed on a per-test basis.
123 1. Pick the category for the new test or fallback to `misc-tests` if not sure. For
124 an easy start copy an existing `test.sh` script from some test that might be
125 close to the purpose of your new test.
127 * Use the highest unused number in the sequence, write a short descriptive title
128 and join by dashes `-`.
130 * Write a short description of the bug and how it's tested to the comment at the
131 begining of `test.sh`.
133 * Write the test commands, comment anything that's not obvious.
135 * Test your test. Use the `TEST` variable to jump right to your test:
137 $ make TEST=012\* tests-misc # from top directory
138 $ TEST=012\* ./misc-tests.sh # from tests/
141 * The commit changelog should reference a commit that either introduced or
142 fixed the bug (or both). Subject line of the shall mention the name of the
143 new directory for ease of search, eg. `btrfs-progs: tests: add 012-subvolume-sync-must-wait`