xref: /netbsd-src/external/gpl2/xcvs/dist/TESTS (revision a7c918477dd5f12c1da816ba05caf44eab2d06d6)
1*a7c91847SchristosTo run the tests:
2*a7c91847Schristos
3*a7c91847Schristos	$ make check
4*a7c91847Schristos
5*a7c91847SchristosNote that if your /bin/sh doesn't support shell functions, you'll
6*a7c91847Schristoshave to try something like this, where "/bin/sh5" is replaced by the
7*a7c91847Schristospathname of a shell which handles normal shell functions:
8*a7c91847Schristos
9*a7c91847Schristos	$ make SHELL=/bin/sh5 check
10*a7c91847Schristos
11*a7c91847SchristosAlso note that you must be logged in as a regular user, not root.
12*a7c91847Schristos
13*a7c91847SchristosWARNING:  This test can take quite a while to run, esp. if your
14*a7c91847Schristosdisks are slow or over-loaded.
15*a7c91847Schristos
16*a7c91847SchristosThe tests work in /tmp/cvs-sanity (which the tests create) by default.
17*a7c91847SchristosIf for some reason you want them to work in a different directory, you
18*a7c91847Schristoscan set the TESTDIR environment variable to the desired location
19*a7c91847Schristosbefore running them.
20*a7c91847Schristos
21*a7c91847SchristosThe tests use a number of tools (awk, expr, id, tr, etc.) that are not
22*a7c91847Schristosrequired for running CVS itself.  In most cases, the standard vendor-
23*a7c91847Schristossupplied versions of these tools work just fine, but there are some
24*a7c91847Schristosexceptions -- expr in particular is heavily used and many vendor
25*a7c91847Schristosversions are deficient in one way or another.  Note that some vendors
26*a7c91847Schristosprovide multiple versions of tools (typically an ancient, traditional
27*a7c91847Schristosversion and a new, standards-conforming version), so you may already
28*a7c91847Schristoshave a usable version even if the default version isn't.  If you don't
29*a7c91847Schristoshave a suitable tool, you can probably get one from the GNU Project (see
30*a7c91847Schristoshttp://www.gnu.org).  At this writting, expr and id are both part of the
31*a7c91847SchristosGNU shellutils package, tr is part of the GNU textutils package, and awk
32*a7c91847Schristosis part of the GNU gawk package.  The test script tries to verify that
33*a7c91847Schristosthe tools exist and are usable; if not, it tries to find the GNU
34*a7c91847Schristosversions and use them instead.  If it can't find the GNU versions
35*a7c91847Schristoseither, it will print an error message and, depending on the severity of
36*a7c91847Schristosthe deficiency, it may exit.  There are environment variables you can
37*a7c91847Schristosset to use a particular version of a tool -- see the test script
38*a7c91847Schristos(src/sanity.sh) for details.
39*a7c91847Schristos
40*a7c91847SchristosSome of the tests use fairly long command lines -- this usually isn't a
41*a7c91847Schristosproblem, but if you have a very short command line length limit (or a
42*a7c91847Schristoslot of environment variables), you may run into trouble.  Also, some of
43*a7c91847Schristosthe tests expect your local timezone to be an integral number of hours
44*a7c91847Schristosfrom UTC -- if you usually use a fractional timezone, use a different
45*a7c91847Schristos(integral) timezone when running the tests to avoid spurious failures.
46*a7c91847Schristos
47*a7c91847SchristosIf running the tests produces the output "FAIL:" followed by the name
48*a7c91847Schristosof the test that failed, then the details on the failure are in the
49*a7c91847Schristosfile check.log.  If it says "exit status is " followed by a number,
50*a7c91847Schristosthen the exit status of the command under test was not what the test
51*a7c91847Schristosexpected.  If it says "** expected:" followed by a regular expression
52*a7c91847Schristosfollowed by "** got:" followed by some text, then the regular
53*a7c91847Schristosexpression is the output which the test expected, and the text is the
54*a7c91847Schristosoutput which the command under test actually produced.  In some cases
55*a7c91847Schristosyou'll have to look closely to see how they differ; the debug_check_log
56*a7c91847Schristosscript in the contrib directory can assist in this process.
57*a7c91847Schristos
58*a7c91847SchristosIf output from "make remotecheck" is out of order compared to what is
59*a7c91847Schristosexpected (for example,
60*a7c91847Schristos
61*a7c91847Schristos   a
62*a7c91847Schristos   b
63*a7c91847Schristos   cvs foo: this is a demo
64*a7c91847Schristos
65*a7c91847Schristosis expected and
66*a7c91847Schristos
67*a7c91847Schristos   a
68*a7c91847Schristos   cvs foo: this is a demo
69*a7c91847Schristos   b
70*a7c91847Schristos
71*a7c91847Schristosis output), this is probably a well-known bug in the CVS server
72*a7c91847Schristos(search for "out-of-order" in src/server.c for a comment explaining
73*a7c91847Schristosthe cause).  It is a real pain in running the testsuite, but if you
74*a7c91847Schristosare lucky and/or your machine is fast and/or lightly loaded, you won't
75*a7c91847Schristosrun into it.  Running the tests again might succeed if the first run
76*a7c91847Schristosfailed in this manner.
77*a7c91847Schristos
78*a7c91847SchristosFor more information on what goes in check.log, and how the tests are
79*a7c91847Schristosrun in general, you'll have to read sanity.sh.  Depending on just what
80*a7c91847Schristosyou are looking for, and how familiar you are with the Bourne shell
81*a7c91847Schristosand regular expressions, it will range from relatively straightforward
82*a7c91847Schristosto obscure.
83*a7c91847Schristos
84*a7c91847SchristosIf you choose to submit a bug report based on tests failing, be
85*a7c91847Schristosaware that, as with all bug reports, you may or may not get a
86*a7c91847Schristosresponse, and your odds might be better if you include enough
87*a7c91847Schristosinformation to reproduce the bug, an analysis of what is going
88*a7c91847Schristoswrong (if you have the time to provide one), etc.  The check.log
89*a7c91847Schristosfile is the first place to look.
90*a7c91847Schristos
91*a7c91847SchristosABOUT STDOUT AND STDERR
92*a7c91847Schristos***********************
93*a7c91847Schristos
94*a7c91847SchristosThe sanity.sh test framework combines stdout and stderr and for tests
95*a7c91847Schristosto pass requires that output appear in the given order.  Some people
96*a7c91847Schristossuggest that ordering between stdout and stderr should not be
97*a7c91847Schristosrequired, or to put it another way, that the out-of-order bug referred
98*a7c91847Schristosto above, and similar behaviors, should be considered features, or at
99*a7c91847Schristosleast tolerable.  The reasoning behind the current behavior is that
100*a7c91847Schristoshaving the output appear in a certain order is the correct behavior
101*a7c91847Schristosfor users using CVS interactively--that users get confused if the
102*a7c91847Schristosorder is unpredictable.
103*a7c91847Schristos
104*a7c91847SchristosABOUT TEST FRAMEWORKS
105*a7c91847Schristos*********************
106*a7c91847Schristos
107*a7c91847SchristosPeople periodically suggest using dejagnu or some other test
108*a7c91847Schristosframework.  A quick look at sanity.sh should make it clear that there
109*a7c91847Schristosare indeed reasons to be dissatisfied with the status quo.  Ideally a
110*a7c91847Schristosreplacement framework would achieve the following:
111*a7c91847Schristos
112*a7c91847Schristos1.  Widely portable, including to a wide variety of unices, NT, Win95,
113*a7c91847SchristosOS/2, VMS, probably DOS and Win3, etc.
114*a7c91847Schristos
115*a7c91847Schristos2.  Nicely match extended regular expressions of unlimited length.
116*a7c91847Schristos
117*a7c91847Schristos3.  Be freely redistributable, and if possible already the kind of
118*a7c91847Schristosthing people might have already installed.  The harder it is to get
119*a7c91847Schristosand install the framework, the less people will run the tests.
120*a7c91847Schristos
121*a7c91847SchristosThe various contenders are:
122*a7c91847Schristos
123*a7c91847Schristos* Bourne shell and GNU expr (the status quo).  Falls short on #1
124*a7c91847Schristos(we've only tried unix and NT, although MKS might help with other DOS
125*a7c91847Schristosmutants).  #3 is pretty good (the main dependency is GNU expr which is
126*a7c91847Schristosfairly widely available).
127*a7c91847Schristos
128*a7c91847Schristos* Bourne shell with a new regexp matcher we would distribute with
129*a7c91847SchristosCVS.  This means maintaining a regexp matcher and the makefiles which
130*a7c91847Schristosgo with it.  Not clearly a win over Bourne shell and GNU expr.
131*a7c91847Schristos
132*a7c91847Schristos* Bourne shell, and use sed to remove variable portions of output, and
133*a7c91847Schristosthus produce a form that can be compared with cmp or diff (this
134*a7c91847Schristossidesteps the need for a full regular expression matcher as mentioned
135*a7c91847Schristosin #2 above).  The C News tests are said to work this way.  This would
136*a7c91847Schristosappear to rely on variable portions of output having a certain syntax
137*a7c91847Schristosand might spuriously recognize them out of context (this issue needs
138*a7c91847Schristosmore investigation; it isn't clear how big a problem it is in
139*a7c91847Schristospractice).  Same portability issues as the other choices based on the
140*a7c91847SchristosBourne shell.
141*a7c91847Schristos
142*a7c91847Schristos* Dejagnu.  This is overkill; most of dejagnu is either unnecessary
143*a7c91847Schristos(e.g. libraries for communicating with target boards) or undesirable
144*a7c91847Schristos(e.g. the code which stats every file in sight to find the tests).  On
145*a7c91847Schristosthe plus side, dejagnu is probably closer than any of the other
146*a7c91847Schristoschoices to having everything which is needed already there.
147*a7c91847Schristos
148*a7c91847Schristos* Write our own small framework directly in tcl and distribute with
149*a7c91847SchristosCVS.  The tests would look much like dejagnu tests, but we'd avoid the
150*a7c91847Schristosunnecessary baggage.  The only dependency would be on tcl (that is,
151*a7c91847Schristoswish).
152*a7c91847Schristos
153*a7c91847Schristos* perl or python or <any other serious contenders here?>
154*a7c91847Schristos
155*a7c91847SchristosIt is worth thinking about how to:
156*a7c91847Schristos
157*a7c91847Schristosa.  include spaces in arguments which we pass to the program under
158*a7c91847Schristostest (sanity.sh dotest cannot do this; see test rcs-9 for a
159*a7c91847Schristosworkaround).
160*a7c91847Schristos
161*a7c91847Schristosb.  pass stdin to the program under test (sanity.sh, again, handles
162*a7c91847Schristosthis by bypassing dotest).
163*a7c91847Schristos
164*a7c91847Schristosc.  have a send-expect type dialog with the program under test
165*a7c91847Schristos    (e.g. see server-7 or pserver-4 which want to talk the CVS
166*a7c91847Schristos    protocol, or the many tests which need to answer the prompt of "cvs
167*a7c91847Schristos    release", e.g. deep-5).
168*a7c91847Schristos
169*a7c91847SchristosABOUT ADDING YOUR OWN TESTS
170*a7c91847Schristos***************************
171*a7c91847Schristos
172*a7c91847SchristosAs stated in the HACKING file, patches are not accepted without documentation
173*a7c91847Schristosand tests.  Many people seem to be scared off by the large size of the
174*a7c91847Schristossanity.sh script, but it is not really very complicated.
175*a7c91847Schristos
176*a7c91847SchristosYou can probably ignore most of the begining of the script.  This section
177*a7c91847Schristosjust sets some environment variables and finds the tools the script needs to
178*a7c91847Schristosrun.
179*a7c91847Schristos
180*a7c91847SchristosThere is one main loop you can find by grepping for "The big loop".  This loop
181*a7c91847Schristosrepeatedly calls a case statement where the individual cases are of the form:
182*a7c91847Schristos
183*a7c91847Schristos    testname)
184*a7c91847Schristos            ...
185*a7c91847Schristos            ;;
186*a7c91847Schristos
187*a7c91847SchristosIf you add a complete new test be sure to add it into the default list of tests
188*a7c91847Schristos(grep for 'tests=' near the begining of the script) as well as the case
189*a7c91847Schristosstatement.  During debugging, be aware that the sanity.sh usage allows for a '-f
190*a7c91847Schristostestname' option to continue through the default list "from" a particular test
191*a7c91847Schristosas well as interpreting everything in argv past the required options as test
192*a7c91847Schristosnames to run individual tests.
193*a7c91847Schristos
194*a7c91847SchristosWithin each major test section, individual tests usually look like:
195*a7c91847Schristos
196*a7c91847Schristos    dotest testname-subtestname "shell command" "optionally multiline regexp"
197*a7c91847Schristos
198*a7c91847SchristosTests should always start in $testdir and create a subdirectory to operate in
199*a7c91847Schristosand remove their cruft and end back in $testdir.  The dotest functions output
200*a7c91847Schristosfailure messages and exit if the shell command exits with the wrong exit code or
201*a7c91847Schristosits stdin/stderr output doesn't match the regexp.  There are a few dotest
202*a7c91847Schristosvariations, most notably dotest_fail for expected non-zero exit codes.
203*a7c91847Schristos
204*a7c91847SchristosOther than that the script is mostly vanilla Bourne shell.  There are a few
205*a7c91847Schristoscommon constructs used for versatility and portability.  You can grep for the
206*a7c91847Schristosones I miss, but here are a few important ones.  I'm leaving off long
207*a7c91847Schristosexplanations after the first few since it probably gives you the idea and the
208*a7c91847Schristosdata is in sanity.sh.
209*a7c91847Schristos
210*a7c91847SchristosSeveral variables contain things intended to make a test writer's job easier.
211*a7c91847SchristosNote that the boolean variables contain shell commands which return true or
212*a7c91847Schristosfalse when executed and are intended to be used like,
213*a7c91847Schristos"if $remote; then ... ; else ... ; fi"
214*a7c91847Schristos
215*a7c91847Schristos
216*a7c91847Schristos   * $testdir   = the directory this test is taking place in
217*a7c91847Schristos                  (CVSROOT=$testdir/cvsroot or CVSROOT=:fork:$testdir/cvsroot)
218*a7c91847Schristos   * $testcvs   = full path to the cvs executable we are testing
219*a7c91847Schristos   * $PLUS      = expr dependant uninterpreted '+' since this can vary
220*a7c91847Schristos   * $DOTSTAR   = expr dependant _interpreted_ .* since some exprs don't match
221*a7c91847Schristos                  EOL
222*a7c91847Schristos   * $username  = the username of the user running the tests
223*a7c91847Schristos   * $username8 = the first 8 characters of $username, output by some system
224*a7c91847Schristos                  and CVS commands
225*a7c91847Schristos   * $anyusername
226*a7c91847Schristos                = regexp to match any valid system or CVS username
227*a7c91847Schristos   * $hostname  = regexp to match a hostname
228*a7c91847Schristos   * $SPROG     = regexp to match server progname in CVS error messages.  For
229*a7c91847Schristos                  tests run in local and remote mode, this is usually the
230*a7c91847Schristos                  string to test for, since some messages can be printed either
231*a7c91847Schristos                  by the CVS client or CVS server, dependant on the mode.  In
232*a7c91847Schristos                  local mode it will = $CPROG.
233*a7c91847Schristos   * $CPROG     = regexp to match client progname in CVS error messages.  Use
234*a7c91847Schristos                  this to match error messages known to be printed only from
235*a7c91847Schristos                  the CVS client.
236*a7c91847Schristos   * $remote    = ':' (true) or 'false', depending on whether the script is
237*a7c91847Schristos                  running with a remote CVSROOT
238*a7c91847Schristos   * $keep      = ':' (true) or 'false'.  When set, the first test run will
239*a7c91847Schristos                  leave any files and directories it created in $testdir and
240*a7c91847Schristos                  exit when complete.
241*a7c91847Schristos   * $servercvs = cvs executable to be run as CVS_SERVER in remote testing
242*a7c91847Schristos   * $testcvs_server_support
243*a7c91847Schristos                = ':' (true) or 'false', depending whether server support was
244*a7c91847Schristos                  detected in the ${testcvs} executable.
245*a7c91847Schristos   * $tempfile  = a regex to match a temporary file name, as generated by
246*a7c91847Schristos                  the cvs_temp_file function.
247*a7c91847Schristos   * $tempname  = a regex to match the full path to a temporary file generated
248*a7c91847Schristos                  by cvs_temp_file (always set to `$TMPDIR/$tempfile').
249*a7c91847Schristos
250*a7c91847SchristosAnd, of course, some characters like '.' in regexps need to be '\' escaped when
251*a7c91847Schristosyou mean them literally.  Some characters may be interpreted by the shell,
252*a7c91847Schristose.g. backquotes and '$', are usually either escaped or replaced with '.'.
253*a7c91847Schristosdotest adds the final '$' anchor to the regexp itself and all the expr
254*a7c91847Schristosimplementations I know of implicitly supply the start anchor ('^').
255*a7c91847Schristos
256*a7c91847SchristosIf you only make a few mistakes, the work is, of course, still usable, though we
257*a7c91847Schristosmay send the patch back to you for repair.  :)
258