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