common: move _scratch_metadump to common/xfs
[xfstests-dev.git] / README
1 _______________________
2 BUILDING THE FSQA SUITE
3 _______________________
4
5 - cd into the xfstests directory
6 - install prerequisite packages
7   For example, for Ubuntu:
8         sudo apt-get install xfslibs-dev uuid-dev libtool-bin \
9         e2fsprogs automake gcc libuuid1 quota attr make \
10         libacl1-dev libaio-dev xfsprogs libgdbm-dev gawk fio dbench \
11         uuid-runtime python sqlite3 liburing-dev
12   For Fedora, RHEL, or CentOS:
13         yum install acl attr automake bc dbench dump e2fsprogs fio \
14         gawk gcc indent libtool lvm2 make psmisc quota sed \
15         xfsdump xfsprogs \
16         libacl-devel libaio-devel libuuid-devel \
17         xfsprogs-devel btrfs-progs-devel python sqlite liburing-devel
18         (Older distributions may require xfsprogs-qa-devel as well.)
19         (Note that for RHEL and CentOS, you may need the EPEL repo.)
20 - run make
21 - run make install
22 - create fsgqa test user ("sudo useradd -m fsgqa")
23 - create fsgqa group ("sudo groupadd fsgqa")
24 - create 123456-fsgqa test user ("sudo useradd 123456-fsgqa")
25   this 2nd user creation step can be safely skipped if your system
26   doesn't support names starting with digits, only a handful of tests
27   require it.
28 - create fsgqa2 test user ("sudo useradd fsgqa2")
29
30 ______________________
31 USING THE FSQA SUITE
32 ______________________
33
34 Preparing system for tests:
35
36     - compile XFS into your kernel or load XFS modules
37     - install administrative tools specific to the filesystem you wish to test
38     - If you wish to run the udf components of the suite install
39       mkudffs. Also download and build the Philips UDF Verification Software
40       from https://www.lscdweb.com/registered/udf_verifier.html, then copy the udf_test
41       binary to xfstests/src/. If you wish to disable UDF verification test
42       set the environment variable DISABLE_UDF_TEST to 1.
43
44     - create one or two partitions to use for testing
45         - one TEST partition
46             - format as XFS, mount & optionally populate with
47               NON-IMPORTANT stuff
48         - one SCRATCH partition (optional)
49             - leave empty and expect this partition to be clobbered
50               by some tests.  If this is not provided, many tests will
51               not be run.
52               (SCRATCH and TEST must be two DIFFERENT partitions)
53               OR
54         - for btrfs only: some btrfs test cases will need 3 or more independent
55               SCRATCH disks which should be set using SCRATCH_DEV_POOL (for eg:
56               SCRATCH_DEV_POOL="/dev/sda /dev/sdb /dev/sdc") with which
57               SCRATCH_DEV should be unused by the tester, and for the legacy
58               support SCRATCH_DEV will be set to the first disk of the
59               SCRATCH_DEV_POOL by xfstests script.
60
61     - setup your environment
62         Quick start:
63         - copy local.config.example to local.config and edit as needed
64         Or:
65         - setenv TEST_DEV "device containing TEST PARTITION"
66         - setenv TEST_DIR "mount point of TEST PARTITION"
67         - optionally:
68              - setenv SCRATCH_DEV "device containing SCRATCH PARTITION" OR
69                (btrfs only) setenv SCRATCH_DEV_POOL "to 3 or more SCRATCH disks for
70                testing btrfs raid concepts"
71              - setenv SCRATCH_MNT "mount point for SCRATCH PARTITION"
72              - setenv TAPE_DEV "tape device for testing xfsdump"
73              - setenv RMT_TAPE_DEV "remote tape device for testing xfsdump"
74              - setenv RMT_IRIXTAPE_DEV "remote IRIX tape device for testing xfsdump"
75              - setenv SCRATCH_LOGDEV "device for scratch-fs external log"
76              - setenv SCRATCH_RTDEV "device for scratch-fs realtime data"
77              - setenv TEST_LOGDEV "device for test-fs external log"
78              - setenv TEST_RTDEV "device for test-fs realtime data"
79              - if TEST_LOGDEV and/or TEST_RTDEV, these will always be used.
80              - if SCRATCH_LOGDEV and/or SCRATCH_RTDEV, the USE_EXTERNAL
81                environment variable set to "yes" will enable their use.
82              - setenv DIFF_LENGTH "number of diff lines to print from a failed test",
83                by default 10, set to 0 to print the full diff
84              - setenv FSTYP "the filesystem you want to test", the filesystem
85                type is devised from the TEST_DEV device, but you may want to
86                override it; if unset, the default is 'xfs'
87              - setenv FSSTRESS_AVOID and/or FSX_AVOID, which contain options
88                added to the end of fsstresss and fsx invocations, respectively,
89                in case you wish to exclude certain operational modes from these
90                tests.
91              - set TEST_XFS_REPAIR_REBUILD=1 to have _check_xfs_filesystem
92                run xfs_repair -n to check the filesystem; xfs_repair to rebuild
93                metadata indexes; and xfs_repair -n (a third time) to check the
94                results of the rebuilding.
95              - xfs_scrub, if present, will always check the test and scratch
96                filesystems if they are still online at the end of the test.
97                It is no longer necessary to set TEST_XFS_SCRUB.
98              - setenv LOGWRITES_DEV to a block device to use for power fail
99                testing.
100              - setenv PERF_CONFIGNAME to a arbitrary string to be used for
101                identifying the test setup for running perf tests.  This should
102                be different for each type of performance test you wish to run so
103                that relevant results are compared.  For example 'spinningrust'
104                for configurations that use spinning disks and 'nvme' for tests
105                using nvme drives.
106              - set USE_KMEMLEAK=yes to scan for memory leaks in the kernel
107                after every test, if the kernel supports kmemleak.
108              - set KEEP_DMESG=yes to keep dmesg log after test
109              - Set TEST_FS_MODULE_RELOAD=1 to unload the module and reload
110                it between test invocations.  This assumes that the name of
111                the module is the same as FSTYP.
112              - Set DUMP_CORRUPT_FS=1 to record metadata dumps of XFS
113                filesystems if a filesystem check fails.
114
115         - or add a case to the switch in common/config assigning
116           these variables based on the hostname of your test
117           machine
118         - or add these variables to a file called local.config and keep that
119           file in your workarea.
120
121     - if testing xfsdump, make sure the tape devices have a
122       tape which can be overwritten.
123
124     - make sure $TEST_DEV is a mounted XFS partition
125     - make sure that $SCRATCH_DEV or $SCRATCH_DEV_POOL contains nothing useful
126
127 Running tests:
128
129     - cd xfstests
130     - By default the tests suite will run all the tests in the auto group. These
131       are the tests that are expected to function correctly as regression tests,
132       and it excludes tests that exercise conditions known to cause machine
133       failures (i.e. the "dangerous" tests).
134     - ./check '*/001' '*/002' '*/003'
135     - ./check '*/06?'
136     - Groups of tests maybe ran by: ./check -g [group(s)]
137       See the 'group' file for details on groups
138     - If you want to run all tests regardless of what group they are in
139       (including dangerous tests), use the "all" group: ./check -g all
140     - To randomize test order: ./check -r [test(s)]
141     - You can explicitly specify NFS/CIFS/OVERLAY, otherwise
142       the filesystem type will be autodetected from $TEST_DEV:
143         - for running nfs tests: ./check -nfs [test(s)]
144         - for running cifs/smb3 tests: ./check -cifs [test(s)]
145         - for overlay tests: ./check -overlay [test(s)]
146           The TEST and SCRATCH partitions should be pre-formatted
147           with another base fs, where the overlay dirs will be created
148
149
150     The check script tests the return value of each script, and
151     compares the output against the expected output. If the output
152     is not as expected, a diff will be output and an .out.bad file
153     will be produced for the failing test.
154
155     Unexpected console messages, crashes and hangs may be considered
156     to be failures but are not necessarily detected by the QA system.
157
158 __________________________
159 ADDING TO THE FSQA SUITE
160 __________________________
161
162
163 Creating new tests scripts:
164
165     Use the "new" script.
166
167 Test script environment:
168
169     When developing a new test script keep the following things in
170     mind.  All of the environment variables and shell procedures are
171     available to the script once the "common/rc" file has been
172     sourced.
173
174      1. The tests are run from an arbitrary directory.  If you want to
175         do operations on an XFS filesystem (good idea, eh?), then do
176         one of the following:
177
178         (a) Create directories and files at will in the directory
179             $TEST_DIR ... this is within an XFS filesystem and world
180             writeable.  You should cleanup when your test is done,
181             e.g. use a _cleanup shell procedure in the trap ... see
182             001 for an example.  If you need to know, the $TEST_DIR
183             directory is within the filesystem on the block device
184             $TEST_DEV.
185
186         (b) mkfs a new XFS filesystem on $SCRATCH_DEV, and mount this
187             on $SCRATCH_MNT. Call the the _require_scratch function
188             on startup if you require use of the scratch partition.
189             _require_scratch does some checks on $SCRATCH_DEV &
190             $SCRATCH_MNT and makes sure they're unmounted. You should
191             cleanup when your test is done, and in particular unmount
192             $SCRATCH_MNT.
193             Tests can make use of $SCRATCH_LOGDEV and $SCRATCH_RTDEV
194             for testing external log and realtime volumes - however,
195             these tests need to simply "pass" (e.g. cat $seq.out; exit
196             - or default to an internal log) in the common case where
197             these variables are not set.
198
199      2. You can safely create temporary files that are not part of the
200         filesystem tests (e.g. to catch output, prepare lists of things
201         to do, etc.) in files named $tmp.<anything>.  The standard test
202         script framework created by "new" will initialize $tmp and
203         cleanup on exit.
204
205      3. By default, tests are run as the same uid as the person
206         executing the control script "check" that runs the test scripts.
207
208      4. Some other useful shell procedures:
209
210         _get_fqdn               - echo the host's fully qualified
211                                   domain name
212
213         _get_pids_by_name       - one argument is a process name, and
214                                   return all of the matching pids on
215                                   standard output
216
217         _within_tolerance       - fancy numerical "close enough is good
218                                   enough" filter for deterministic
219                                   output ... see comments in
220                                   common/filter for an explanation
221
222         _filter_date            - turn ctime(3) format dates into the
223                                   string DATE for deterministic
224                                   output
225
226         _cat_passwd,            - dump the content of the password
227         _cat_group                or group file (both the local file
228                                   and the content of the NIS database
229                                   if it is likely to be present)
230
231      5. General recommendations, usage conventions, etc.:
232         - When the content of the password or group file is
233           required, get it using the _cat_passwd and _cat_group
234           functions, to ensure NIS information is included if NIS
235           is active.
236         - When calling getfacl in a test, pass the "-n" argument so
237           that numeric rather than symbolic identifiers are used in
238           the output.
239         - When creating a new test, it is possible to enter a custom name
240           for the file. Filenames are in form NNN-custom-name, where NNN
241           is automatically added by the ./new script as an unique ID,
242           and "custom-name" is the optional string entered into a prompt
243           in the ./new script. It can contain only alphanumeric characters
244           and dash. Note the "NNN-" part is added automatically.
245
246 Verified output:
247
248     Each test script has a name, e.g. 007, and an associated
249     verified output, e.g. 007.out.
250
251     It is important that the verified output is deterministic, and
252     part of the job of the test script is to filter the output to
253     make this so.  Examples of the sort of things that need filtering:
254
255     - dates
256     - pids
257     - hostnames
258     - filesystem names
259     - timezones
260     - variable directory contents
261     - imprecise numbers, especially sizes and times
262
263 Pass/failure:
264
265     The script "check" may be used to run one or more tests.
266
267     Test number $seq is deemed to "pass" when:
268     (a) no "core" file is created,
269     (b) the file $seq.notrun is not created,
270     (c) the exit status is 0, and
271     (d) the output matches the verified output.
272
273     In the "not run" case (b), the $seq.notrun file should contain a
274     short one-line summary of why the test was not run.  The standard
275     output is not checked, so this can be used for a more verbose
276     explanation and to provide feedback when the QA test is run
277     interactively.
278
279
280     To force a non-zero exit status use:
281         status=1
282         exit
283
284     Note that:
285         exit 1
286     won't have the desired effect because of the way the exit trap
287     works.
288
289     The recent pass/fail history is maintained in the file "check.log".
290     The elapsed time for the most recent pass for each test is kept
291     in "check.time".
292
293     The compare-failures script in tools/ may be used to compare failures
294     across multiple runs, given files containing stdout from those runs.
295
296 __________________
297 SUBMITTING PATCHES
298 __________________
299
300 Send patches to the fstests mailing list at fstests@vger.kernel.org.