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