Make out of space test more general so I can try different scenarios more easily...
[xfstests-dev.git] / README
1 ______________________
2 USING THE XFS QA SUITE
3 ______________________
4
5 Preparing system for tests:
6
7     - compile XFS into your kernel or load XFS modules
8     - install user tools including mkfs.xfs, xfs_db & xfs_bmap
9     
10     - create two partitions to use for testing
11         - one TEST partition
12             - format as XFS, mount & optionally populate with 
13               NON-IMPORTANT stuff
14         - one SCRATCH partition
15             - leave empty and expect this partition to be clobbered
16               by some tests.
17               
18         (these must be two DIFFERENT partitions)
19               
20     - setup your environment
21         - setenv TEST_DEV "device containing TEST PARTITION"
22         - setenv TEST_DIR "mount point of TEST PARTITION"   
23         - setenv SCRATCH_DEV "device containing SCRATCH PARTITION"
24         - setenv SCRATCH_MNT "mount point for SCRATCH PARTITION"
25         - setenv TAPE_DEV "tape device for testing xfsdump"
26         - setenv RMT_TAPE_DEV "remote tape device for testing xfsdump"
27         - setenv RMT_IRIXTAPE_DEV "remote IRIX tape device for testing xfsdump"
28         - optionally:
29              - setenv SCRATCH_LOGDEV "device for scratch-fs external log"
30              - setenv SCRATCH_RTDEV "device for scratch-fs realtime data"
31              - setenv TEST_LOGDEV "device for test-fs external log"
32              - setenv TEST_RTDEV "device for test-fs realtime data"
33              - if TEST_LOGDEV and/or TEST_RTDEV, these will always be used.
34              - if SCRATCH_LOGDEV and/or SCRATCH_RTDEV, the USE_EXTERNAL
35                environment variable set to "yes" will enable their use.
36         - or add a case to the switch in common.config assigning
37           these variables based on the hostname of your test
38           machine
39
40     - if testing xfsdump, make sure the tape devices have a
41       tape which can be overwritten.
42           
43     - make sure $TEST_DEV is a mounted XFS partition
44     - make sure that $SCRATCH_DEV contains nothing useful
45     
46 Running tests:
47
48     - cd cmd/xfs/stress
49     - ./check 001 002 003 ... 
50     
51     The check script tests the return value of each script, and
52     compares the output against the expected output. If the output
53     is not as expected, a diff will be output and an .out.bad file
54     will be produced for the failing test.
55     
56     Unexpected console messages, crashes and hangs may be considered
57     to be failures but are not necesarily detected by the QA system.
58
59 __________________________ 
60 ADDING TO THE XFS QA SUITE
61 __________________________
62
63
64 Creating new tests scripts:
65
66     Use the "new" script.
67
68 Test script environment:
69
70     When developing a new test script keep the following things in
71     mind.  All of the environment variables and shell procedures are
72     available to the script once the "common.rc" file has been
73     sourced.
74
75      1. The tests are run from an arbitrary directory.  If you want to
76         do operations on an XFS filesystem (good idea, eh?), then do
77         one of the following:
78
79         (a) Create directories and files at will in the directory
80             $TEST_DIR ... this is within an XFS filesystem and world
81             writeable.  You should cleanup when your test is done,
82             e.g. use a _cleanup shell procedure in the trap ... see
83             001 for an example.  If you need to know, the $TEST_DIR
84             direcotry is within the filesystem on the block device
85             $TEST_DEV.
86
87         (b) mkfs a new XFS filesystem on $SCRATCH_DEV, and mount this
88             on $SCRATCH_MNT. Call the the _require_scratch function 
89             on startup if you require use of the scratch partition.
90             _require_scratch does some checks on $SCRATCH_DEV & 
91             $SCRATCH_MNT and makes sure they're unmounted. You should 
92             cleanup when your test is done, and in particular unmount 
93             $SCRATCH_MNT.
94             Tests can make use of $SCRATCH_LOGDEV and $SCRATCH_RTDEV
95             for testing external log and realtime volumes - however,
96             these tests need to simply "pass" (e.g. cat $seq.out; exit
97             - or default to an internal log) in the common case where
98             these variables are not set.
99
100      2. You can safely create temporary files that are not part of the
101         filesystem tests (e.g. to catch output, prepare lists of things
102         to do, etc.) in files named $tmp.<anything>.  The standard test
103         script framework created by "new" will initialize $tmp and
104         cleanup on exit.
105
106      3. By default, tests are run as the same uid as the person
107         executing the control script "check" that runs the test scripts.
108
109         If you need to be root, add a call to the shell procedure
110         _need_to_be_root ... this will do nothing or exit with an
111         error message depending on your current uid.
112
113      4. Some other useful shell procedures:
114
115         _get_fqdn               - echo the host's fully qualified
116                                   domain name
117
118         _get_pids_by_name       - one argument is a process name, and
119                                   return all of the matching pids on
120                                   standard output
121
122         _within_tolerance       - fancy numerical "close enough is good
123                                   enough" filter for deterministic
124                                   output ... see comments in
125                                   common.filter for an explanation
126
127         _filter_date            - turn ctime(3) format dates into the
128                                   string DATE for deterministic
129                                   output
130
131 Verified output:
132
133     Each test script has a numerical name, e.g. 007, and an associated
134     verified output, e.g. 007.out.
135
136     It is important that the verified output is deterministic, and
137     part of the job of the test script is to filter the output to
138     make this so.  Examples of the sort of things that need filtering:
139
140     - dates
141     - pids
142     - hostnames
143     - filesystem names
144     - timezones
145     - variable directory contents
146     - imprecise numbers, especially sizes and times
147
148     Use the "remake" script to recreate the verified output for one
149     or more tests.
150
151 Pass/failure:
152
153     The script "check" may be used to run one or more tests.
154
155     Test number $seq is deemed to "pass" when:
156     (a) no "core" file is created,
157     (b) the file $seq.notrun is not created,
158     (c) the exit status is 0, and
159     (d) the output matches the verified output.
160
161     In the "not run" case (b), the $seq.notrun file should contain a
162     short one-line summary of why the test was not run.  The standard
163     output is not checked, so this can be used for a more verbose
164     explanation and to provide feedback when the QA test is run
165     interactively.
166
167
168     To force a non-zero exit status use:
169         status=1
170         exit
171
172     Note that:
173         exit 1
174     won't have the desired effect becuase of the way the exit trap
175     works.
176
177     The recent pass/fail history is maintained in the file "check.log".
178     The elapsed time for the most recent pass for each test is kept
179     in "check.time".