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