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