/contrib/cvs/TESTS

https://bitbucket.org/freebsd/freebsd-head/ · #! · 240 lines · 191 code · 49 blank · 0 comment · 0 complexity · bec13f94acb4083d57d835ba72e173a6 MD5 · raw file

  1. To run the tests:
  2. $ make check
  3. Note that if your /bin/sh doesn't support shell functions, you'll
  4. have to try something like this, where "/bin/sh5" is replaced by the
  5. pathname of a shell which handles normal shell functions:
  6. $ make SHELL=/bin/sh5 check
  7. Also note that you must be logged in as a regular user, not root.
  8. WARNING: This test can take quite a while to run, esp. if your
  9. disks are slow or over-loaded.
  10. The tests work in /tmp/cvs-sanity (which the tests create) by default.
  11. If for some reason you want them to work in a different directory, you
  12. can set the TESTDIR environment variable to the desired location
  13. before running them.
  14. The tests use a number of tools (awk, expr, id, tr, etc.) that are not
  15. required for running CVS itself. In most cases, the standard vendor-
  16. supplied versions of these tools work just fine, but there are some
  17. exceptions -- expr in particular is heavily used and many vendor
  18. versions are deficient in one way or another. Note that some vendors
  19. provide multiple versions of tools (typically an ancient, traditional
  20. version and a new, standards-conforming version), so you may already
  21. have a usable version even if the default version isn't. If you don't
  22. have a suitable tool, you can probably get one from the GNU Project (see
  23. http://www.gnu.org). At this writting, expr and id are both part of the
  24. GNU shellutils package, tr is part of the GNU textutils package, and awk
  25. is part of the GNU gawk package. The test script tries to verify that
  26. the tools exist and are usable; if not, it tries to find the GNU
  27. versions and use them instead. If it can't find the GNU versions
  28. either, it will print an error message and, depending on the severity of
  29. the deficiency, it may exit. There are environment variables you can
  30. set to use a particular version of a tool -- see the test script
  31. (src/sanity.sh) for details.
  32. Some of the tests use fairly long command lines -- this usually isn't a
  33. problem, but if you have a very short command line length limit (or a
  34. lot of environment variables), you may run into trouble. Also, some of
  35. the tests expect your local timezone to be an integral number of hours
  36. from UTC -- if you usually use a fractional timezone, use a different
  37. (integral) timezone when running the tests to avoid spurious failures.
  38. If running the tests produces the output "FAIL:" followed by the name
  39. of the test that failed, then the details on the failure are in the
  40. file check.log. If it says "exit status is " followed by a number,
  41. then the exit status of the command under test was not what the test
  42. expected. If it says "** expected:" followed by a regular expression
  43. followed by "** got:" followed by some text, then the regular
  44. expression is the output which the test expected, and the text is the
  45. output which the command under test actually produced. In some cases
  46. you'll have to look closely to see how they differ.
  47. If output from "make remotecheck" is out of order compared to what is
  48. expected (for example,
  49. a
  50. b
  51. cvs foo: this is a demo
  52. is expected and
  53. a
  54. cvs foo: this is a demo
  55. b
  56. is output), this is probably a well-known bug in the CVS server
  57. (search for "out-of-order" in src/server.c for a comment explaining
  58. the cause). It is a real pain in running the testsuite, but if you
  59. are lucky and/or your machine is fast and/or lightly loaded, you won't
  60. run into it. Running the tests again might succeed if the first run
  61. failed in this manner.
  62. For more information on what goes in check.log, and how the tests are
  63. run in general, you'll have to read sanity.sh. Depending on just what
  64. you are looking for, and how familiar you are with the Bourne shell
  65. and regular expressions, it will range from relatively straightforward
  66. to obscure.
  67. If you choose to submit a bug report based on tests failing, be
  68. aware that, as with all bug reports, you may or may not get a
  69. response, and your odds might be better if you include enough
  70. information to reproduce the bug, an analysis of what is going
  71. wrong (if you have the time to provide one), etc. The check.log
  72. file is the first place to look.
  73. ABOUT STDOUT AND STDERR
  74. ***********************
  75. The sanity.sh test framework combines stdout and stderr and for tests
  76. to pass requires that output appear in the given order. Some people
  77. suggest that ordering between stdout and stderr should not be
  78. required, or to put it another way, that the out-of-order bug referred
  79. to above, and similar behaviors, should be considered features, or at
  80. least tolerable. The reasoning behind the current behavior is that
  81. having the output appear in a certain order is the correct behavior
  82. for users using CVS interactively--that users get confused if the
  83. order is unpredictable.
  84. ABOUT TEST FRAMEWORKS
  85. *********************
  86. People periodically suggest using dejagnu or some other test
  87. framework. A quick look at sanity.sh should make it clear that there
  88. are indeed reasons to be dissatisfied with the status quo. Ideally a
  89. replacement framework would achieve the following:
  90. 1. Widely portable, including to a wide variety of unices, NT, Win95,
  91. OS/2, VMS, probably DOS and Win3, etc.
  92. 2. Nicely match extended regular expressions of unlimited length.
  93. 3. Be freely redistributable, and if possible already the kind of
  94. thing people might have already installed. The harder it is to get
  95. and install the framework, the less people will run the tests.
  96. The various contenders are:
  97. * Bourne shell and GNU expr (the status quo). Falls short on #1
  98. (we've only tried unix and NT, although MKS might help with other DOS
  99. mutants). #3 is pretty good (the main dependency is GNU expr which is
  100. fairly widely available).
  101. * Bourne shell with a new regexp matcher we would distribute with
  102. CVS. This means maintaining a regexp matcher and the makefiles which
  103. go with it. Not clearly a win over Bourne shell and GNU expr.
  104. * Bourne shell, and use sed to remove variable portions of output, and
  105. thus produce a form that can be compared with cmp or diff (this
  106. sidesteps the need for a full regular expression matcher as mentioned
  107. in #2 above). The C News tests are said to work this way. This would
  108. appear to rely on variable portions of output having a certain syntax
  109. and might spuriously recognize them out of context (this issue needs
  110. more investigation; it isn't clear how big a problem it is in
  111. practice). Same portability issues as the other choices based on the
  112. Bourne shell.
  113. * Dejagnu. This is overkill; most of dejagnu is either unnecessary
  114. (e.g. libraries for communicating with target boards) or undesirable
  115. (e.g. the code which stats every file in sight to find the tests). On
  116. the plus side, dejagnu is probably closer than any of the other
  117. choices to having everything which is needed already there.
  118. * Write our own small framework directly in tcl and distribute with
  119. CVS. The tests would look much like dejagnu tests, but we'd avoid the
  120. unnecessary baggage. The only dependency would be on tcl (that is,
  121. wish).
  122. * perl or python or <any other serious contenders here?>
  123. It is worth thinking about how to:
  124. a. include spaces in arguments which we pass to the program under
  125. test (sanity.sh dotest cannot do this; see test rcs-9 for a
  126. workaround).
  127. b. pass stdin to the program under test (sanity.sh, again, handles
  128. this by bypassing dotest).
  129. c. have a send-expect type dialog with the program under test
  130. (e.g. see server-7 or pserver-4 which want to talk the CVS
  131. protocol, or the many tests which need to answer the prompt of "cvs
  132. release", e.g. deep-5).
  133. ABOUT ADDING YOUR OWN TESTS
  134. ***************************
  135. As stated in the HACKING file, patches are not accepted without documentation
  136. and tests. Many people seem to be scared off by the large size of the
  137. sanity.sh script, but it is not really very complicated.
  138. You can probably ignore most of the begining of the script. This section
  139. just sets some environment variables and finds the tools the script needs to
  140. run.
  141. There is one main loop you can find by grepping for "The big loop". This loop
  142. repeatedly calls a case statement where the individual cases are of the form:
  143. testname)
  144. ...
  145. ;;
  146. If you add a complete new test be sure to add it into the default list of tests
  147. (grep for 'tests=' near the begining of the script) as well as the case
  148. statement. During debugging, be aware that the sanity.sh usage allows for a '-f
  149. testname' option to continue through the default list "from" a particular test
  150. as well as interpreting everything in argv past the required options as test
  151. names to run individual tests.
  152. Within each major test section, individual tests usually look like:
  153. dotest testname-subtestname "shell command" "optionally multiline regexp"
  154. Tests should always start in $testdir and create a subdirectory to operate in
  155. and remove their cruft and end back in $testdir. The dotest functions output
  156. failure messages and exit if the shell command exits with the wrong exit code or
  157. its stdin/stderr output doesn't match the regexp. There are a few dotest
  158. variations, most notably dotest_fail for expected non-zero exit codes.
  159. Other than that the script is mostly vanilla Bourne shell. There are a few
  160. constructs used for versatility and portability. You can grep for the ones I
  161. miss, but here are a few important ones. I'm leaving off long explanations
  162. after the first few since it probably gives you the idea and the data is in
  163. sanity.sh.
  164. Note that the boolean variables contain shell commands which return true or
  165. false when executed and are intended to be used like,
  166. "if $remote; then ... ; else ... ; fi"
  167. * $testdir = the directory this test is taking place in
  168. (CVSROOT=$testdir/cvsroot or
  169. CVSROOT=:fork:$testdir/cvsroot)
  170. * $testcvs = full path to the cvs executable we are testing
  171. * $PLUS = expr dependant uninterpreted '+' since this can vary
  172. * $DOTSTAR = expr dependant _interpreted_ .* since some exprs don't
  173. match EOL
  174. * $username = the username of the user running the tests
  175. * $username8 = the first 8 characters of $username, output by some
  176. system and CVS commands
  177. * $anyusername = regexp to match any valid system or CVS username
  178. * $hostname = regexp to match a hostname
  179. * $PROG = regexp to match progname in CVS error messages
  180. * $remote = ':' (true) or 'false', depending on whether the script is
  181. running with a remote CVSROOT
  182. * $keep = ':' (true) or 'false'. When set, the first test run will
  183. leave any files and directories it created in $testdir and
  184. exit when complete.
  185. And, of course, some characters like '.' in regexps need to be '\' escaped when
  186. you mean them literally. Some characters may be interpreted by the shell,
  187. e.g. backquotes and '$', are usually either escaped or replaced with '.'.
  188. dotest adds the final '$' anchor to the regexp itself and all the expr
  189. implementations I know of implicitly supply the start anchor ('^').
  190. If you only make a few mistakes, the work is, of course, still usable, though we
  191. may send the patch back to you for repair. :)