1 <!-- $PostgreSQL: pgsql/doc/src/sgml/regress.sgml,v 1.53 2006/07/19 02:37:00 tgl Exp $ -->
4 <title id="regress-title">Regression Tests</title>
6 <indexterm zone="regress">
7 <primary>regression tests</primary>
10 <indexterm zone="regress">
11 <primary>test</primary>
15 The regression tests are a comprehensive set of tests for the SQL
16 implementation in <productname>PostgreSQL</productname>. They test
17 standard SQL operations as well as the extended capabilities of
18 <productname>PostgreSQL</productname>.
21 <sect1 id="regress-run">
22 <title>Running the Tests</title>
25 The regression tests can be run against an already installed and
26 running server, or using a temporary installation within the build
27 tree. Furthermore, there is a <quote>parallel</quote> and a
28 <quote>sequential</quote> mode for running the tests. The
29 sequential method runs each test script in turn, whereas the
30 parallel method starts up multiple server processes to run groups
31 of tests in parallel. Parallel testing gives confidence that
32 interprocess communication and locking are working correctly. For
33 historical reasons, the sequential test is usually run against an
34 existing installation and the parallel method against a temporary
35 installation, but there are no technical reasons for this.
39 To run the regression tests after building but before installation,
44 in the top-level directory. (Or you can change to
45 <filename>src/test/regress</filename> and run the command there.)
46 This will first build several auxiliary files, such as
47 some sample user-defined trigger functions, and then run the test driver
48 script. At the end you should see something like
51 ======================
53 ======================
56 or otherwise a note about which tests failed. See <xref
57 linkend="regress-evaluation"> below before assuming that a
58 <quote>failure</> represents a serious problem.
62 Because this test method runs a temporary server, it will not work
63 when you are the root user (since the server will not start as root).
64 If you already did the build as root, you do not have to start all
65 over. Instead, make the regression test directory writable by
66 some other user, log in as that user, and restart the tests.
69 <prompt>root# </prompt><userinput>chmod -R a+w src/test/regress</userinput>
70 <prompt>root# </prompt><userinput>chmod -R a+w contrib/spi</userinput>
71 <prompt>root# </prompt><userinput>su - joeuser</userinput>
72 <prompt>joeuser$ </prompt><userinput>cd <replaceable>top-level build directory</></userinput>
73 <prompt>joeuser$ </prompt><userinput>gmake check</userinput>
75 (The only possible <quote>security risk</quote> here is that other
76 users might be able to alter the regression test results behind
77 your back. Use common sense when managing user permissions.)
80 Alternatively, run the tests after installation.
84 If you have configured <productname>PostgreSQL</productname> to install
85 into a location where an older <productname>PostgreSQL</productname>
86 installation already exists, and you perform <literal>gmake check</>
87 before installing the new version, you may find that the tests fail
88 because the new programs try to use the already-installed shared
89 libraries. (Typical symptoms are complaints about undefined symbols.)
90 If you wish to run the tests before overwriting the old installation,
91 you'll need to build with <literal>configure --disable-rpath</>.
92 It is not recommended that you use this option for the final installation,
97 The parallel regression test starts quite a few processes under your
98 user ID. Presently, the maximum concurrency is twenty parallel test
99 scripts, which means sixty processes: there's a server process, a
100 <application>psql</>, and usually a shell parent process for the
101 <application>psql</> for each test script.
102 So if your system enforces a per-user limit on the number of processes,
103 make sure this limit is at least seventy-five or so, else you may get
104 random-seeming failures in the parallel test. If you are not in
105 a position to raise the limit, you can cut down the degree of parallelism
106 by setting the <literal>MAX_CONNECTIONS</> parameter. For example,
108 gmake MAX_CONNECTIONS=10 check
110 runs no more than ten tests concurrently.
114 To run the tests after installation<![%standalone-ignore;[ (see <xref linkend="installation">)]]>,
115 initialize a data area and start the
116 server, <![%standalone-ignore;[as explained in <xref linkend="runtime">, ]]> then type
120 or for a parallel test
122 gmake installcheck-parallel
124 The tests will expect to contact the server at the local host and the
125 default port number, unless directed otherwise by <envar>PGHOST</envar> and
126 <envar>PGPORT</envar> environment variables.
130 The source distribution also contains regression tests for the optional
131 procedural languages and for some of the <filename>contrib</> modules.
132 At present, these tests can be used only against an already-installed
133 server. To run the tests for all procedural languages that have been
134 built and installed, change to the <filename>src/pl</> directory of the
139 You can also do this in any of the subdirectories of <filename>src/pl</>
140 to run tests for just one procedural language. To run the tests for all
141 <filename>contrib</> modules that have them, change to the
142 <filename>contrib</> directory of the build tree and type
146 The <filename>contrib</> modules must have been built and installed first.
147 You can also do this in a subdirectory of <filename>contrib</> to run
148 the tests for just one module.
152 <sect1 id="regress-evaluation">
153 <title>Test Evaluation</title>
156 Some properly installed and fully functional
157 <productname>PostgreSQL</productname> installations can
158 <quote>fail</quote> some of these regression tests due to
159 platform-specific artifacts such as varying floating-point representation
160 and message wording. The tests are currently evaluated using a simple
161 <command>diff</command> comparison against the outputs
162 generated on a reference system, so the results are sensitive to
163 small system differences. When a test is reported as
164 <quote>failed</quote>, always examine the differences between
165 expected and actual results; you may well find that the
166 differences are not significant. Nonetheless, we still strive to
167 maintain accurate reference files across all supported platforms,
168 so it can be expected that all tests pass.
172 The actual outputs of the regression tests are in files in the
173 <filename>src/test/regress/results</filename> directory. The test
174 script uses <command>diff</command> to compare each output
175 file against the reference outputs stored in the
176 <filename>src/test/regress/expected</filename> directory. Any
177 differences are saved for your inspection in
178 <filename>src/test/regress/regression.diffs</filename>. (Or you
179 can run <command>diff</command> yourself, if you prefer.)
183 If for some reason a particular platform generates a <quote>failure</>
184 for a given test, but inspection of the output convinces you that
185 the result is valid, you can add a new comparison file to silence
186 the failure report in future test runs. See
187 <xref linkend="regress-variant"> for details.
191 <title>Error message differences</title>
194 Some of the regression tests involve intentional invalid input
195 values. Error messages can come from either the
196 <productname>PostgreSQL</productname> code or from the host
197 platform system routines. In the latter case, the messages may
198 vary between platforms, but should reflect similar
199 information. These differences in messages will result in a
200 <quote>failed</quote> regression test that can be validated by
206 <title>Locale differences</title>
209 If you run the tests against an already-installed server that was
210 initialized with a collation-order locale other than C, then
211 there may be differences due to sort order and follow-up
212 failures. The regression test suite is set up to handle this
213 problem by providing alternative result files that together are
214 known to handle a large number of locales.
219 <title>Date and time differences</title>
222 Most of the date and time results are dependent on the time zone
223 environment. The reference files are generated for time zone
224 <literal>PST8PDT</literal> (Berkeley, California), and there will be
225 apparent failures if the tests are not run with that time zone setting.
226 The regression test driver sets environment variable
227 <envar>PGTZ</envar> to <literal>PST8PDT</literal>, which normally
228 ensures proper results.
233 <title>Floating-point differences</title>
236 Some of the tests involve computing 64-bit floating-point numbers (<type>double
237 precision</type>) from table columns. Differences in
238 results involving mathematical functions of <type>double
239 precision</type> columns have been observed. The <literal>float8</> and
240 <literal>geometry</> tests are particularly prone to small differences
241 across platforms, or even with different compiler optimization options.
242 Human eyeball comparison is needed to determine the real
243 significance of these differences which are usually 10 places to
244 the right of the decimal point.
248 Some systems display minus zero as <literal>-0</>, while others
249 just show <literal>0</>.
253 Some systems signal errors from <function>pow()</function> and
254 <function>exp()</function> differently from the mechanism
255 expected by the current <productname>PostgreSQL</productname>
261 <title>Row ordering differences</title>
264 You might see differences in which the same rows are output in a
265 different order than what appears in the expected file. In most cases
266 this is not, strictly speaking, a bug. Most of the regression test
267 scripts are not so pedantic as to use an <literal>ORDER BY</> for every single
268 <literal>SELECT</>, and so their result row orderings are not well-defined
269 according to the letter of the SQL specification. In practice, since we are
270 looking at the same queries being executed on the same data by the same
271 software, we usually get the same result ordering on all platforms, and
272 so the lack of <literal>ORDER BY</> isn't a problem. Some queries do exhibit
273 cross-platform ordering differences, however. When testing against an
274 already-installed server, ordering differences can also be caused by
275 non-C locale settings or non-default parameter settings, such as custom values
276 of <varname>work_mem</> or the planner cost parameters.
280 Therefore, if you see an ordering difference, it's not something to
281 worry about, unless the query does have an <literal>ORDER BY</> that your
282 result is violating. But please report it anyway, so that we can add an
283 <literal>ORDER BY</> to that particular query and thereby eliminate the bogus
284 <quote>failure</quote> in future releases.
288 You might wonder why we don't order all the regression test queries explicitly
289 to get rid of this issue once and for all. The reason is that that would
290 make the regression tests less useful, not more, since they'd tend
291 to exercise query plan types that produce ordered results to the
292 exclusion of those that don't.
297 <title>Insufficient stack depth</title>
300 If the <literal>errors</literal> test results in a server crash
301 at the <literal>select infinite_recurse()</> command, it means that
302 the platform's limit on process stack size is smaller than the
303 <![%standalone-ignore;[<xref linkend="guc-max-stack-depth">]]>
304 <![%standalone-include;[<literal>max_stack_depth</literal>]]>
305 parameter indicates. This
306 can be fixed by running the server under a higher stack
307 size limit (4MB is recommended with the default value of
308 <varname>max_stack_depth</>). If you are unable to do that, an
309 alternative is to reduce the value of <varname>max_stack_depth</>.
314 <title>The <quote>random</quote> test</title>
317 The <literal>random</literal> test script is intended to produce
318 random results. In rare cases, this causes the random regression
321 diff results/random.out expected/random.out
323 should produce only one or a few lines of differences. You need
324 not worry unless the random test fails repeatedly.
329 <!-- We might want to move the following section into the developer's guide. -->
330 <sect1 id="regress-variant">
331 <title>Variant Comparison Files</title>
334 Since some of the tests inherently produce environment-dependent
335 results, we have provided ways to specify alternative <quote>expected</>
336 result files. Each regression test can have several comparison files
337 showing possible results on different platforms. There are two
338 independent mechanisms for determining which comparison file is used
343 The first mechanism allows comparison files to be selected for
344 specific platforms. There is a mapping file,
345 <filename>src/test/regress/resultmap</filename>, that defines
346 which comparison file to use for each platform.
347 To eliminate bogus test <quote>failures</quote> for a particular platform,
348 you first choose or make a variant result file, and then add a line to the
349 <filename>resultmap</filename> file.
353 Each line in the mapping file is of the form
355 testname/platformpattern=comparisonfilename
357 The test name is just the name of the particular regression test
358 module. The platform pattern is a pattern in the style of the Unix
359 tool <command>expr</> (that is, a regular expression with an implicit
360 <literal>^</literal> anchor at the start). It is matched against the
361 platform name as printed by <command>config.guess</command>.
362 The comparison file name is the base name of the substitute result
367 For example: some systems interpret very small floating-point values
368 as zero, rather than reporting an underflow error. This causes a
369 few differences in the <filename>float8</> regression test.
370 Therefore, we provide a variant comparison file,
371 <filename>float8-small-is-zero.out</filename>, which includes
372 the results to be expected on these systems. To silence the bogus
373 <quote>failure</quote> message on <systemitem>OpenBSD</systemitem>
374 platforms, <filename>resultmap</filename> includes
376 float8/i.86-.*-openbsd=float8-small-is-zero
378 which will trigger on any machine for which the output of
379 <command>config.guess</command> matches <literal>i.86-.*-openbsd</literal>.
381 in <filename>resultmap</> select the variant comparison file for other
382 platforms where it's appropriate.
386 The second selection mechanism for variant comparison files is
387 much more automatic: it simply uses the <quote>best match</> among
388 several supplied comparison files. The regression test driver
389 script considers both the standard comparison file for a test,
390 <literal><replaceable>testname</>.out</>, and variant files named
391 <literal><replaceable>testname</>_<replaceable>digit</>.out</>
392 (where the <replaceable>digit</> is any single digit
393 <literal>0</>-<literal>9</>). If any such file is an exact match,
394 the test is considered to pass; otherwise, the one that generates
395 the shortest diff is used to create the failure report. (If
396 <filename>resultmap</filename> includes an entry for the particular
397 test, then the base <replaceable>testname</> is the substitute
398 name given in <filename>resultmap</filename>.)
402 For example, for the <literal>char</literal> test, the comparison file
403 <filename>char.out</filename> contains results that are expected
404 in the <literal>C</> and <literal>POSIX</> locales, while
405 the file <filename>char_1.out</filename> contains results sorted as
406 they appear in many other locales.
410 The best-match mechanism was devised to cope with locale-dependent
411 results, but it can be used in any situation where the test results
412 cannot be predicted easily from the platform name alone. A limitation of
413 this mechanism is that the test driver cannot tell which variant is
414 actually <quote>correct</> for the current environment; it will just pick
415 the variant that seems to work best. Therefore it is safest to use this
416 mechanism only for variant results that you are willing to consider
417 equally valid in all contexts.
424 <!-- Keep this comment at the end of the file
429 sgml-minimize-attributes:nil
430 sgml-always-quote-attributes:t
433 sgml-parent-document:nil
434 sgml-default-dtd-file:"./reference.ced"
435 sgml-exposed-tags:nil
436 sgml-local-catalogs:("/usr/lib/sgml/catalog")
437 sgml-local-ecat-files:nil