| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 |
"http://www.w3.org/TR/html4/loose.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"> |
| 6 |
<title>The deal.II Testsuite</title> |
| 7 |
<link href="../screen.css" rel="StyleSheet"> |
| 8 |
<meta name="copyright" content="Copyright (C) 1998 - 2024 by the deal.II Authors"> |
| 9 |
<meta name="keywords" content="deal dealii finite elements fem triangulation"> |
| 10 |
<meta http-equiv="content-language" content="en"> |
| 11 |
</head> |
| 12 |
<body> |
| 13 |
|
| 14 |
|
| 15 |
<h1>The deal.II Testsuite</h1> |
| 16 |
|
| 17 |
<p> |
| 18 |
deal.II has a testsuite with thousands of small programs that we run every time |
| 19 |
we make a change to make sure |
| 20 |
that no existing functionality is broken. It is located in the <code>tests/</code> |
| 21 |
directory of the development repository. The expected output for |
| 22 |
every test is stored in an <code>*.output</code> next to the <code>.cc</code> file, |
| 23 |
and when running a test, you are notified if the output differs from the expected |
| 24 |
output. |
| 25 |
</p> |
| 26 |
|
| 27 |
<p> |
| 28 |
These days, every time we add a significant piece of functionality, |
| 29 |
we add at least one new test to the testsuite, and we also do so if |
| 30 |
we fix a bug, in both cases to make sure that future changes do not |
| 31 |
break this functionality (again). Machines running the testsuite |
| 32 |
submit the results to our cdash |
| 33 |
<a href="https://cdash.dealii.org/index.php?project=deal.II">CDash instance</a>, |
| 34 |
a webpage showing the status of our regression tests. |
| 35 |
</p> |
| 36 |
|
| 37 |
<div class="toc"> |
| 38 |
<ol> |
| 39 |
<li><a href="#setup">Setting up the testsuite</a></li> |
| 40 |
<ol> |
| 41 |
<li><a href="#setupbuild">For a build directory</a></li> |
| 42 |
<li><a href="#setupinstalled">For an already installed library</a></li> |
| 43 |
</ol> |
| 44 |
<li><a href="#run">Running the testsuite</a></li> |
| 45 |
<ol> |
| 46 |
<li><a href="#runoutput">How to interpret the output</a></li> |
| 47 |
<li><a href="#coverage">Generating coverage information</a></li> |
| 48 |
</ol> |
| 49 |
<li><a href="#layout">Testsuite development</a></li> |
| 50 |
<ol> |
| 51 |
<li><a href="#layoutgeneral">General layout</a></li> |
| 52 |
<li><a href="#restrictbuild">Restricting tests to build configurations</a></li> |
| 53 |
<li><a href="#restrictfeature">Restricting tests to feature configurations</a></li> |
| 54 |
<li><a href="#mpi">Running tests with MPI</a></li> |
| 55 |
<li><a href="#variants">Tests with multiple comparison files</a></li> |
| 56 |
<li><a href="#expect">Changing condition for success</a></li> |
| 57 |
<li><a href="#layoutaddtests">Adding new tests</a></li> |
| 58 |
<li><a href="#layoutaddcategory">Adding new categories</a></li> |
| 59 |
</ol> |
| 60 |
<li><a href="#submit">Submitting test results</a></li> |
| 61 |
<li><a href="#build_tests">Build tests</a></li> |
| 62 |
<ol> |
| 63 |
<li><a href="#dedicatedbuilds">Dedicated build tests</a></li> |
| 64 |
</ol> |
| 65 |
</ol> |
| 66 |
</div> |
| 67 |
|
| 68 |
<a name="setup"></a> |
| 69 |
<h2>Setting up the testsuite</h2> |
| 70 |
|
| 71 |
<p> |
| 72 |
The testsuite is part of the development sources of deal.II and located |
| 73 |
under the <code>tests</code> subdirectory. The easiest way to obtain |
| 74 |
both of them is to check out the current development sources via git: |
| 75 |
<pre> |
| 76 |
$ git clone https://github.com/dealii/dealii |
| 77 |
</pre> |
| 78 |
</p> |
| 79 |
|
| 80 |
<a name="setupbuild"></a> |
| 81 |
<h3>For a build directory</h3> |
| 82 |
|
| 83 |
<p> |
| 84 |
To enable the testsuite for a given build directory, ensure that |
| 85 |
deal.II is successfully configured and built (installation is not |
| 86 |
necessary). After that you can set up the testsuite via the |
| 87 |
"setup_tests" target: |
| 88 |
<pre> |
| 89 |
$ make setup_tests |
| 90 |
</pre> |
| 91 |
This will set up all tests supported by the current configuration. |
| 92 |
The testsuite can now be run in the current <i>build directory</i> as |
| 93 |
described below. |
| 94 |
</p> |
| 95 |
|
| 96 |
<p> |
| 97 |
The setup can be fine-tuned using the following commands: |
| 98 |
<pre> |
| 99 |
|
| 100 |
$ make prune_tests - removes all testsuite subprojects |
| 101 |
</pre> |
| 102 |
|
| 103 |
<p> |
| 104 |
In addition, when setting up the testsuite, the following environment |
| 105 |
variables can be used to override default behavior when |
| 106 |
calling <code>make setup_tests</code>: |
| 107 |
<pre> |
| 108 |
TEST_TIME_LIMIT |
| 109 |
- The time limit (in seconds) a single test is allowed to take. Defaults |
| 110 |
to 180 seconds |
| 111 |
|
| 112 |
TEST_MPI_RANK_LIMIT |
| 113 |
- Specifies the maximal number of MPI ranks that can be used. If a |
| 114 |
test variant configures a larger number of MPI ranks (via |
| 115 |
.mpirun=N. in the output file) than this limit the test will be |
| 116 |
dropped. The special value 0 enforces no limit. Defaults to 0. |
| 117 |
|
| 118 |
TEST_THREAD_LIMIT |
| 119 |
- Specifies the maximal number of worker threads that can should be |
| 120 |
used by the threading backend. If a test variant configures a larger |
| 121 |
number of threads (via .threads=N. in the output file) than this limit |
| 122 |
the test will be dropped. Note that individual tests might exceed this |
| 123 |
limit by calling MultithreadInfo::set_thread_limit(), or by manually |
| 124 |
creating additional threads. The special value 0 enforces no limit. |
| 125 |
Defaults to 0. |
| 126 |
|
| 127 |
TEST_PICKUP_REGEX |
| 128 |
- A regular expression to select only a subset of tests during setup. |
| 129 |
An empty string is interpreted as a catchall (this is the default). |
| 130 |
</pre> |
| 131 |
For example, |
| 132 |
<pre> |
| 133 |
TEST_PICKUP_REGEX="umfpack" make setup_tests |
| 134 |
</pre> |
| 135 |
will only enable tests which match the string "umfpack" in category or |
| 136 |
name. |
| 137 |
</p> |
| 138 |
|
| 139 |
<a name="setupinstalled"></a> |
| 140 |
<h3>For an already installed library</h3> |
| 141 |
|
| 142 |
<p> |
| 143 |
The testsuite can also be set up for an already installed library |
| 144 |
(starting with version 8.3). For this, create a build directory for |
| 145 |
the testsuite and run cmake pointing to the <code>tests</code> |
| 146 |
subdirectory, e.g., |
| 147 |
<pre> |
| 148 |
$ mkdir tests_for_installed_dealii |
| 149 |
$ cd tests_for_installed_dealii |
| 150 |
$ cmake -DDEAL_II_DIR=/path/to/installed/dealii /path/to/dealii_source/tests |
| 151 |
</pre> |
| 152 |
After that the same configuration targets as described <a |
| 153 |
href="setupbuild">above</a> are available. |
| 154 |
</p> |
| 155 |
|
| 156 |
<a name="run"></a> |
| 157 |
<h2>Running the testsuite</h2> |
| 158 |
|
| 159 |
<p> |
| 160 |
The testsuite can now be run in the <i>build directory</i> via |
| 161 |
<pre> |
| 162 |
$ ctest [-j N] |
| 163 |
</pre> |
| 164 |
Here, <code>N</code> is the number of concurrent tests that should be |
| 165 |
run, in the same way as you can say <code>make -jN</code>. The testsuite |
| 166 |
is huge and will need around 12h on current computers |
| 167 |
running single threaded. |
| 168 |
</p> |
| 169 |
|
| 170 |
<p> |
| 171 |
If you only want to run a subset of tests |
| 172 |
matching a regular expression, or if you want to exclude tests matching |
| 173 |
a regular expression, you can use |
| 174 |
<pre> |
| 175 |
$ ctest [-j N] -R '<positive regular expression>' |
| 176 |
$ ctest [-j N] -E '<negative regular expression>' |
| 177 |
</pre> |
| 178 |
</p> |
| 179 |
|
| 180 |
<p> |
| 181 |
<b>Note:</b> |
| 182 |
Not all tests succeed on every machine even if all computations are |
| 183 |
correct, because your machine generates slightly different floating |
| 184 |
point outputs. To increase the number of tests that work correctly, |
| 185 |
install the |
| 186 |
<a href="http://www.nongnu.org/numdiff/">numdiff</a> tool that compares |
| 187 |
stored and newly created output files based on floating point |
| 188 |
tolerances. To use it, simply export where the <code>numdiff</code> |
| 189 |
executable can be found via the <code>PATH</code> |
| 190 |
environment variable so that it can be found during |
| 191 |
<code>make setup_tests</code>. |
| 192 |
</p> |
| 193 |
|
| 194 |
<a name="runoutput"></a> |
| 195 |
<h3>How to interpret the output</h3> |
| 196 |
|
| 197 |
<p> |
| 198 |
A typical output of a <code>ctest</code> invocation looks like: |
| 199 |
<pre> |
| 200 |
$ ctest -j4 -R "base/thread_validity" |
| 201 |
Test project /tmp/trunk/build |
| 202 |
Start 747: base/thread_validity_01.debug |
| 203 |
Start 748: base/thread_validity_01.release |
| 204 |
Start 775: base/thread_validity_05.debug |
| 205 |
Start 776: base/thread_validity_05.release |
| 206 |
1/24 Test #776: base/thread_validity_05.release ... Passed 1.89 sec |
| 207 |
2/24 Test #748: base/thread_validity_01.release ... Passed 1.89 sec |
| 208 |
Start 839: base/thread_validity_03.debug |
| 209 |
Start 840: base/thread_validity_03.release |
| 210 |
3/24 Test #747: base/thread_validity_01.debug ..... Passed 2.68 sec |
| 211 |
[...] |
| 212 |
Start 1077: base/thread_validity_08.debug |
| 213 |
Start 1078: base/thread_validity_08.release |
| 214 |
16/24 Test #1078: base/thread_validity_08.release ...***Failed 2.86 sec |
| 215 |
18/24 Test #1077: base/thread_validity_08.debug .....***Failed 3.97 sec |
| 216 |
[...] |
| 217 |
|
| 218 |
92% tests passed, 2 tests failed out of 24 |
| 219 |
|
| 220 |
Total Test time (real) = 20.43 sec |
| 221 |
|
| 222 |
The following tests FAILED: |
| 223 |
1077 - base/thread_validity_08.debug (Failed) |
| 224 |
1078 - base/thread_validity_08.release (Failed) |
| 225 |
Errors while running CTest |
| 226 |
</pre> |
| 227 |
If a test failed (like <code>base/thread_validity_08.debug</code> in above |
| 228 |
example output), you might want to find out what exactly went wrong. To |
| 229 |
this end, you can search |
| 230 |
through <code>Testing/Temporary/LastTest.log</code> for the exact output |
| 231 |
of the test, or you can rerun this one test, specifying <code>-V</code> |
| 232 |
to select verbose output of tests: |
| 233 |
<pre> |
| 234 |
$ ctest -V -R "base/thread_validity_08.debug" |
| 235 |
[...] |
| 236 |
test 1077 |
| 237 |
Start 1077: base/thread_validity_08.debug |
| 238 |
|
| 239 |
1077: Test command: [...] |
| 240 |
1077: Test timeout computed to be: 600 |
| 241 |
1077: Test base/thread_validity_08.debug: RUN |
| 242 |
1077: =============================== OUTPUT BEGIN =============================== |
| 243 |
1077: Built target thread_validity_08.debug |
| 244 |
1077: Generating thread_validity_08.debug/output |
| 245 |
1077: terminate called without an active exception |
| 246 |
1077: /bin/sh: line 1: 18030 Aborted [...]/thread_validity_08.debug |
| 247 |
1077: base/thread_validity_08.debug: BUILD successful. |
| 248 |
1077: base/thread_validity_08.debug: RUN failed. Output: |
| 249 |
1077: DEAL::OK. |
| 250 |
1077: gmake[3]: *** [thread_validity_08.debug/output] Error 1 |
| 251 |
1077: gmake[2]: *** [CMakeFiles/thread_validity_08.debug.diff.dir/all] Error 2 |
| 252 |
1077: gmake[1]: *** [CMakeFiles/thread_validity_08.debug.diff.dir/rule] Error 2 |
| 253 |
1077: gmake: *** [thread_validity_08.debug.diff] Error 2 |
| 254 |
1077: |
| 255 |
1077: |
| 256 |
1077: base/thread_validity_08.debug: ****** RUN failed ******* |
| 257 |
1077: |
| 258 |
1077: =============================== OUTPUT END =============================== |
| 259 |
</pre> |
| 260 |
So this specific test aborted in the <code>RUN</code> stage. |
| 261 |
</p> |
| 262 |
|
| 263 |
<p> |
| 264 |
The general output for a successful test <code><test></code> in |
| 265 |
category <code><category></code> for build type |
| 266 |
<code><build></code> is |
| 267 |
<pre> |
| 268 |
xx: Test <category>/<test>.<build>: PASSED |
| 269 |
xx: =============================== OUTPUT BEGIN =============================== |
| 270 |
xx: [...] |
| 271 |
xx: <category>/<test>.<build>: PASSED. |
| 272 |
xx: =============================== OUTPUT END =============================== |
| 273 |
</pre> |
| 274 |
And for a test that fails in stage <code><stage></code>: |
| 275 |
<pre> |
| 276 |
xx: Test <category>/<test>.<build>: <stage> |
| 277 |
xx: =============================== OUTPUT BEGIN =============================== |
| 278 |
xx: [...] |
| 279 |
xx: <category>/<test>.<build>: <stage> failed. [...] |
| 280 |
xx: |
| 281 |
xx: <category>/<test>.<build>: ****** <stage> failed ******* |
| 282 |
xx: =============================== OUTPUT END =============================== |
| 283 |
</pre> |
| 284 |
Hereby, <code><stage></code> indicates the stage in which the |
| 285 |
test failed: |
| 286 |
<ul> |
| 287 |
<li> |
| 288 |
<code>CONFIGURE</code>: only for test in the "build_tests" |
| 289 |
category: The test project failed in the configuration stage |
| 290 |
</li> |
| 291 |
<li> |
| 292 |
<code>BUILD</code>: compilation error occurred |
| 293 |
</li> |
| 294 |
<li> |
| 295 |
<code>RUN</code>: the test executable could not be run / aborted |
| 296 |
</li> |
| 297 |
<li> |
| 298 |
<code>DIFF</code>: the test output differs from the reference output |
| 299 |
</li> |
| 300 |
<li> |
| 301 |
<code>PASSED</code>: the test run successful |
| 302 |
</li> |
| 303 |
</ul> |
| 304 |
Typically, tests fail because the output has changed, and you will see |
| 305 |
this in the DIFF phase of the test. |
| 306 |
</p> |
| 307 |
|
| 308 |
|
| 309 |
<a name="coverage"></a> |
| 310 |
<h3>Generating coverage information</h3> |
| 311 |
|
| 312 |
<p> |
| 313 |
The testsuite can also be used to provide <i>coverage</i> information, |
| 314 |
i.e., data that shows which lines of the library are executed how many |
| 315 |
times by running through all of the tests in the testsuite. This is of |
| 316 |
interest in finding places in the library that are not covered by |
| 317 |
the testsuite and, consequently, are prone to the inadvertent |
| 318 |
introduction of bugs since existing functionality is not subject to |
| 319 |
existing tests. |
| 320 |
</p> |
| 321 |
|
| 322 |
<p> |
| 323 |
To run the testsuite in this mode, essentially, you have to do three |
| 324 |
things: |
| 325 |
<ol> |
| 326 |
<li> |
| 327 |
build the library with appropriate profiling flags |
| 328 |
</li> |
| 329 |
<li> |
| 330 |
run all or some tests (built with the same profiling flags) |
| 331 |
</li> |
| 332 |
<li> |
| 333 |
gather all information and convert them to a viewable format. |
| 334 |
</li> |
| 335 |
</ol> |
| 336 |
In order to achieve the first two, configure the library with |
| 337 |
<pre> |
| 338 |
cmake -DCMAKE_BUILD_TYPE=Debug -DDEAL_II_SETUP_COVERAGE=ON <...> |
| 339 |
</pre> |
| 340 |
You can then build the library and run the tests as usual. |
| 341 |
</p> |
| 342 |
|
| 343 |
<p> |
| 344 |
For the last point, one can in principal use whatever tool one |
| 345 |
wants. That said, the deal.II ctest driver already has builtin |
| 346 |
functionality to gather all profiling files and submit them to cdash |
| 347 |
where we already gather testsuite results |
| 348 |
(see <a href="#submit">below</a>). You can do so by invoking |
| 349 |
<pre> |
| 350 |
ctest -DCOVERAGE=ON <...> -S ../tests/run_testsuite.cmake |
| 351 |
</pre> |
| 352 |
when running the testsuite, or directly by |
| 353 |
<pre> |
| 354 |
ctest <...> -S ../tests/run_coverage.cmake |
| 355 |
</pre> |
| 356 |
</p> |
| 357 |
|
| 358 |
<p> |
| 359 |
At the end of all of this, results will be shown in a separate section |
| 360 |
"Coverage" at the |
| 361 |
<a href="https://cdash.dealii.org/index.php?project=deal.II&display=project" |
| 362 |
target="_top">deal.II cdash site</a>. |
| 363 |
In case you download the coverage report uploader for Codecov via |
| 364 |
<code>contrib/utilities/download_codecov</code>, the coverage |
| 365 |
report will also be uploaded to the |
| 366 |
<a href="https://codecov.io/gh/dealii/dealii" |
| 367 |
target="_top">Codecov dashboard</a>. |
| 368 |
</p> |
| 369 |
|
| 370 |
|
| 371 |
<a name="layout"></a> |
| 372 |
<h2>Testsuite development</h2> |
| 373 |
|
| 374 |
<p> |
| 375 |
The following outlines what you need to know if you want to understand |
| 376 |
how the testsuite actually works, for example because you may want to |
| 377 |
add tests along with the functionality you are currently developing. |
| 378 |
</p> |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
<a name="layoutgeneral"></a> |
| 383 |
<h3>General layout</h3> |
| 384 |
|
| 385 |
<p> |
| 386 |
A test usually consists of a source file and an output file for |
| 387 |
comparison (under the testsuite directory <code>tests</code>): |
| 388 |
<pre> |
| 389 |
category/test.cc |
| 390 |
category/test.output |
| 391 |
</pre> |
| 392 |
<code>category</code> will be one of the existing subdirectory |
| 393 |
under <code>tests/</code>, e.g., <code>lac/</code>, <code>base/</code>, |
| 394 |
or <code>mpi/</code>. Historically, we have grouped tests into the |
| 395 |
directories <code>base/, lac/, deal.II/</code> depending on their |
| 396 |
functionality, and <code>bits/</code> if they were small unit tests, but |
| 397 |
in practice we have not always followed this rigidly. There are also |
| 398 |
more specialized directories <code>trilinos/, petsc/, |
| 399 |
serialization/, mpi/</code> etc, whose meaning is more obvious. |
| 400 |
<code>test.cc</code> must be a regular executable (i.e. having an |
| 401 |
<code>int main()</code> routine). It will be compiled, linked and |
| 402 |
run. The executable should not output anything to <code>cout</code> |
| 403 |
(at least under normal circumstances, i.e. no error condition), |
| 404 |
instead the executable should output to a file <code>output</code> |
| 405 |
in the current working directory. In practice, we rarely write the |
| 406 |
source files completely from scratch, but we find an existing test that |
| 407 |
already does something similar and copy/modify it to fit our needs. |
| 408 |
</p> |
| 409 |
<p> |
| 410 |
For a normal test, <code>ctest</code> will typically run the following 3 |
| 411 |
stages: |
| 412 |
<ul> |
| 413 |
<li> |
| 414 |
<code>BUILD</code>: The build stage generates an executable in |
| 415 |
<code>BUILD_DIR/tests/<category>/<test></code>. |
| 416 |
</li> |
| 417 |
<li> |
| 418 |
<code>RUN</code>: The run stage then invokes the executable in |
| 419 |
the directory where it is located. By convention, each test |
| 420 |
either prints its test results directly to <code>stdout</code>, |
| 421 |
or directly into a file called <code>output</code> (in the |
| 422 |
current working directory). The latter takes precedence. |
| 423 |
The output (via stdout or file) will then be located in |
| 424 |
<code>BUILD_DIR/tests/<category>/<test>/output</code>. |
| 425 |
If the run fails (e.g. because the program aborts with an error |
| 426 |
code) the file <code>output</code> is renamed to |
| 427 |
<code>failing_output</code>. |
| 428 |
</li> |
| 429 |
<li> |
| 430 |
<code>DIFF</code>: As a last stage the generated output file will |
| 431 |
be compared to |
| 432 |
<code>SOURCE_DIR/tests/<category>/<test>[...].output</code>. |
| 433 |
and stored in |
| 434 |
<code>BUILD_DIR/tests/<category>/<test>/diff</code>. |
| 435 |
If the diff fails the file <code>diff</code> is renamed to |
| 436 |
<code>failing_diff</code>. |
| 437 |
</li> |
| 438 |
</ul> |
| 439 |
</p> |
| 440 |
|
| 441 |
|
| 442 |
<a name="restrictbuild"></a> |
| 443 |
<h3>Restricting tests to build configurations</h3> |
| 444 |
|
| 445 |
<p> |
| 446 |
Comparison file can actually be named in a more complex way than |
| 447 |
just <code>category/test.output</code>. In pseudo code: |
| 448 |
<pre> |
| 449 |
category/test.[with_<string>(<=|>=|=|<|>)<on|off|version>.]* |
| 450 |
[mpirun=<N|all>.][threads=<N|all>.][expect=<y>.][exclusive.][<debug|release>.](output|run_only) |
| 451 |
</pre> |
| 452 |
Normally, a test will be set up so that it runs twice, once in debug and |
| 453 |
once in release configuration. |
| 454 |
If a specific test can only be run in debug or release configurations but |
| 455 |
not in both it is possible to restrict the setup by prepending |
| 456 |
<code>.debug</code> or <code>.release</code> directly before |
| 457 |
<code>.output</code>, e.g.: |
| 458 |
<pre> |
| 459 |
category/test.debug.output |
| 460 |
</pre> |
| 461 |
This way, the test will only be set up to build and run against the debug |
| 462 |
library. If a test should run in both configurations but, for some |
| 463 |
reason, produces different output (e.g., because it triggers an |
| 464 |
assertion in debug mode), then you can just provide two different output |
| 465 |
files: |
| 466 |
<pre> |
| 467 |
category/test.debug.output |
| 468 |
category/test.release.output |
| 469 |
</pre> |
| 470 |
</p> |
| 471 |
|
| 472 |
<a name="restrictfeature"></a> |
| 473 |
<h3>Restricting tests to feature configurations</h3> |
| 474 |
<p> |
| 475 |
In a similar vein as for build configurations, it is possible to restrict |
| 476 |
tests to specific feature configurations, e.g., |
| 477 |
<pre> |
| 478 |
category/test.with_umfpack=on.output, or |
| 479 |
category/test.with_zlib=off.output |
| 480 |
</pre> |
| 481 |
These tests will only be set up if the specified feature was configured. |
| 482 |
<p><b>Note:</b> For CMake variables indicating whether sub-packages of third party libraries |
| 483 |
were detected, like <code>DEAL_II_TRILINOS_WITH_BELOS</code> or <code>DEAL_II_PETSC_WITH_HYPRE</code> |
| 484 |
the correct syntax is adding an additional <code>with_</code>, |
| 485 |
i.e. <code>with_trilinos_with_belos=on|off</code>. |
| 486 |
</p> |
| 487 |
It is possible to provide different output files for disabled/enabled |
| 488 |
features, e.g., |
| 489 |
<pre> |
| 490 |
category/test.with_64bit_indices=on.output |
| 491 |
category/test.with_64bit_indices=off.output |
| 492 |
</pre> |
| 493 |
Furthermore, a test can be restricted to be run only if specific |
| 494 |
versions of a feature are available. For example |
| 495 |
<pre> |
| 496 |
category/test.with_trilinos.geq.11.14.1.output |
| 497 |
</pre> |
| 498 |
will only be run if (a) trilinos is available, i.e., |
| 499 |
<code>DEAL_II_WITH_TRILINOS=TRUE</code> and (b) if trilinos is at least |
| 500 |
of version 11.14.1. Supported operators are |
| 501 |
<code>=</code>, <code>.le.;</code>, <code>.ge.</code>, <code>.leq.</code>, |
| 502 |
<code>.geq.</code>. |
| 503 |
</p> |
| 504 |
<p> |
| 505 |
It is also possible to declare multiple constraints subsequently, e.g. |
| 506 |
<pre> |
| 507 |
category/test.with_umfpack=on.with_zlib=on.output |
| 508 |
</pre> |
| 509 |
</p> |
| 510 |
<p> |
| 511 |
<b>Note:</b> The tests in some subdirectories of <code>tests/</code> are |
| 512 |
automatically run only if some feature is enabled. In this case a |
| 513 |
feature constraint encoded in the output file name is redundant and |
| 514 |
should be avoided. In particular, this holds for subdirectories |
| 515 |
<code>distributed_grids</code>, <code>lapack</code>, |
| 516 |
<code>metis</code>, <code>petsc</code>, <code>slepc</code>, |
| 517 |
<code>trilinos</code>, <code>umfpack</code>, <code>gla</code>, and |
| 518 |
<code>mpi</code> |
| 519 |
</p> |
| 520 |
|
| 521 |
|
| 522 |
<a name="mpi"></a> |
| 523 |
<h3>Running tests with MPI or a specific thread pool size</h3> |
| 524 |
<p> |
| 525 |
If a test should be run with MPI in parallel, the number of MPI |
| 526 |
processes <code>N</code> with which a program needs to be run for |
| 527 |
comparison with a given output file is specified as follows: |
| 528 |
<pre> |
| 529 |
category/test.mpirun=N.output |
| 530 |
</pre> |
| 531 |
It is quite typical for an MPI-enabled test to have multiple output |
| 532 |
files for different numbers of MPI processes. |
| 533 |
|
| 534 |
Similarly, the thread pool size of a test can be specified by using |
| 535 |
<code>threads=N</code>, where <code>N</code> is the number of |
| 536 |
concurrent worker threads that should be initialized: |
| 537 |
<pre> |
| 538 |
category/test.threads=N.output |
| 539 |
</pre> |
| 540 |
This declaration is equivalent to setting the environment variable |
| 541 |
<code>DEAL_II_NUM_THREADS</code>, or calling |
| 542 |
<code>MultithreadInfo::set_thread_limit()</code> by hand. |
| 543 |
</p> |
| 544 |
|
| 545 |
<p> |
| 546 |
In order to account for the increased computational workload of MPI |
| 547 |
parallel code the testsuite will add a processing weight to |
| 548 |
individual MPI tests equal to half of the number of MPI ranks that |
| 549 |
ensures that the machine the testsuite runs on is at most |
| 550 |
overcommitted by a factor of 2. Thread concurrency is not accounted |
| 551 |
for. |
| 552 |
|
| 553 |
This behavior is modified for performance tests. Here, the |
| 554 |
processing weight is taken directly to be the product of the number |
| 555 |
of MPI ranks times the number of threads. |
| 556 |
|
| 557 |
Particularly sensitive timing tests that have to be run |
| 558 |
exclusively without any other test running concurrently can be |
| 559 |
annotated with the <code>.exclusive</code> keyword: |
| 560 |
<pre> |
| 561 |
category/test.exclusive.output |
| 562 |
</pre> |
| 563 |
This ensures that the test in question always runs "in serial" without |
| 564 |
another test scheduled concurrently. |
| 565 |
</p> |
| 566 |
|
| 567 |
<a name="variants"></a> |
| 568 |
<h3>Tests with multiple comparison files</h3> |
| 569 |
<p> |
| 570 |
Sometimes it is necessary to provide multiple comparison files for a |
| 571 |
single test, for example because you want to test code on multiple |
| 572 |
platforms that produce different output files that, nonetheless, all |
| 573 |
should be considered correct. An example would be tests that use the |
| 574 |
<code>rand()</code> function that is implemented differently on |
| 575 |
different platforms. Additional comparison files have the same path |
| 576 |
as the main comparison file (in this case <code>test.output</code>) |
| 577 |
followed by a dot and a variant description: |
| 578 |
<pre> |
| 579 |
category/test.output |
| 580 |
category/test.output.2 |
| 581 |
category/test.output.3 |
| 582 |
category/test.output.4 |
| 583 |
</pre> |
| 584 |
The testsuite will try to match the output against all variants in |
| 585 |
alphabetical order starting with the main output file. |
| 586 |
</p> |
| 587 |
|
| 588 |
<p> |
| 589 |
<b>Warning:</b> This mechanism is only meant as a last resort for |
| 590 |
tests where <i>no</i> alternative approach is viable. Especially, |
| 591 |
consider first to |
| 592 |
<ol> |
| 593 |
<li> make the test more robust such that differences can be |
| 594 |
expressed in round-off errors detectable by numdiff. |
| 595 |
<li> restrict comparison files to specific |
| 596 |
<a href="#restrictfeature">versions of an external feature</a>. |
| 597 |
</ol> |
| 598 |
</p> |
| 599 |
|
| 600 |
<p> |
| 601 |
<b>Note:</b> The main comparison file (i.e., the one ending in |
| 602 |
<code>output</code>) is mandatory. Otherwise, no test will be |
| 603 |
configured. |
| 604 |
</p> |
| 605 |
|
| 606 |
|
| 607 |
<a name="expect"></a> |
| 608 |
<h3>Changing condition for success</h3> |
| 609 |
<p> |
| 610 |
Normally a test is considered to be successful if all test stages |
| 611 |
could be run and the test reached the <code>PASSED</code> stage (see |
| 612 |
the <a href="#runoutput">output description</a> section for details). |
| 613 |
If (for some reason) the test should succeed ending at a specific |
| 614 |
test stage different than <code>PASSED</code> you can specify it via |
| 615 |
<code>expect=<stage></code>, e.g.: |
| 616 |
<pre> |
| 617 |
category/test.expect=run.output |
| 618 |
</pre> |
| 619 |
</p> |
| 620 |
<p> |
| 621 |
The testsuite also supports the special file ending |
| 622 |
<code>.run_only</code> that indicates that the diff stage should be |
| 623 |
skipped in order to reach the <code>PASSED</code> stage. You can |
| 624 |
specify the keyword by changing the file ending from |
| 625 |
<code>.output</code> to <code>.run_only</code>: |
| 626 |
<pre> |
| 627 |
category/test.run_only |
| 628 |
</pre> |
| 629 |
Note that this is semantically different from specifying |
| 630 |
<code>expect=diff.output</code>: The expect keyword requires that a |
| 631 |
test reaches a specified stage but <i>fails</i> in it. In this case |
| 632 |
the test has to reach the <code>DIFF</code> stage but fail it. |
| 633 |
</p> |
| 634 |
|
| 635 |
|
| 636 |
<a name="layoutaddtests"></a> |
| 637 |
<h3>Adding new tests</h3> |
| 638 |
|
| 639 |
<p> |
| 640 |
We typically add one or more new tests every |
| 641 |
time we add new functionality to the library or fix a bug. If you |
| 642 |
want to contribute code to the library, you should do this |
| 643 |
as well. Here's how: you need a testcase and a file with the |
| 644 |
expected output. |
| 645 |
</p> |
| 646 |
|
| 647 |
<h4>The testcase</h4> |
| 648 |
<p> |
| 649 |
For the testcase, we usually start from one of the existing tests, copy |
| 650 |
and modify it to where it does what we'd like to test. Alternatively, |
| 651 |
you can also start from a template like this: |
| 652 |
<pre> |
| 653 |
// ------------------------------------------------------------------------ |
| 654 |
// |
| 655 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 656 |
// Copyright (C) 2024 by the deal.II authors |
| 657 |
// |
| 658 |
// This file is part of the deal.II library. |
| 659 |
// |
| 660 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 661 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 662 |
// governing the source code and code contributions can be found in |
| 663 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 664 |
// |
| 665 |
// ------------------------------------------------------------------------ |
| 666 |
|
| 667 |
// a short (a few lines) description of what the program does |
| 668 |
|
| 669 |
#include "../tests.h" |
| 670 |
|
| 671 |
// all include files you need here |
| 672 |
|
| 673 |
int main () |
| 674 |
{ |
| 675 |
// Initialize deallog for test output. |
| 676 |
// This also reroutes deallog output to a file "output". |
| 677 |
initlog(); |
| 678 |
|
| 679 |
// your testcode here: |
| 680 |
int i = 0; |
| 681 |
deallog << i << std::endl; |
| 682 |
|
| 683 |
return 0; |
| 684 |
} |
| 685 |
</pre> |
| 686 |
|
| 687 |
<p>This code opens an output file <code>output</code> in the current working |
| 688 |
directory and then writes all output you generate to it, through the |
| 689 |
<code>deallog</code> stream. The <code>deallog</code> stream works like |
| 690 |
any other <code>std::ostream</code> except that it does a few more |
| 691 |
things behind the scenes that are helpful in this context. In above |
| 692 |
case, we only write a zero to the output file. Most tests of course |
| 693 |
write computed data to the output file to make sure that whatever we |
| 694 |
compute is what we got when the test was first written. |
| 695 |
</p> |
| 696 |
|
| 697 |
<p> |
| 698 |
There are a number of directories where you can put a new test. |
| 699 |
Extensive tests of individual classes or groups of classes |
| 700 |
have traditionally been into the <code>base/</code>, |
| 701 |
<code>lac/</code>, <code>deal.II/</code>, <code>fe/</code>, |
| 702 |
<code>hp/</code>, or <code>multigrid/</code> directories, depending on |
| 703 |
where the classes that are tested are located. More atomic tests often go |
| 704 |
into <code>bits/</code>. There are also |
| 705 |
directories for PETSc and Trilinos wrapper functionality. |
| 706 |
</p> |
| 707 |
|
| 708 |
<h4>An expected output</h4> |
| 709 |
|
| 710 |
<p> |
| 711 |
In order to run your new test, copy it to an appropriate category and |
| 712 |
create an empty comparison file for it: |
| 713 |
<pre> |
| 714 |
category/my_new_test.cc |
| 715 |
category/my_new_test.output |
| 716 |
</pre> |
| 717 |
Now, rerun |
| 718 |
<pre> |
| 719 |
$ make setup_tests |
| 720 |
</pre> |
| 721 |
so that your new test is picked up. After that it is possible to |
| 722 |
invoke it with |
| 723 |
<pre> |
| 724 |
$ ctest -V -R "category/my_new_test" |
| 725 |
</pre> |
| 726 |
</p> |
| 727 |
|
| 728 |
<p> |
| 729 |
If you run your new test executable this way, the test should compile |
| 730 |
and run successfully but fail in the diff stage (because of the empty |
| 731 |
comparison file). You will get an output file |
| 732 |
<code>BUILD_DIR/category/my_new_test/output</code>. Take a look at it to |
| 733 |
make sure that the output is what you had expected. (For complex tests, |
| 734 |
it may sometimes be impossible to say whether the output is correct, and |
| 735 |
in this case we sometimes just take it to make |
| 736 |
sure that future invocations of the test yield the same results.) |
| 737 |
</p> |
| 738 |
|
| 739 |
<p> |
| 740 |
The next step is to copy and rename this output file to the source |
| 741 |
directory and replace the original comparison file with it: |
| 742 |
<pre> |
| 743 |
category/my_new_test.output |
| 744 |
</pre> |
| 745 |
At this point running the test again should be successful: |
| 746 |
<pre> |
| 747 |
$ ctest -V -R "category/my_new_test" |
| 748 |
</pre> |
| 749 |
</p> |
| 750 |
|
| 751 |
<a name="layoutaddcategory"></a> |
| 752 |
<h2>Adding new categories</h2> |
| 753 |
|
| 754 |
<p> |
| 755 |
If you want to create a new category in the testsuite, create an new |
| 756 |
folder under <cmake>./tests</cmake> that is named accordingly and put |
| 757 |
a <code>CMakeLists.txt</code> file into it containing |
| 758 |
</p> |
| 759 |
<pre> |
| 760 |
cmake_minimum_required(VERSION 3.13.4) |
| 761 |
include(../setup_testsubproject.cmake) |
| 762 |
project(testsuite CXX) |
| 763 |
include(${DEAL_II_TARGET_CONFIG}) |
| 764 |
deal_ii_pickup_tests() |
| 765 |
</pre> |
| 766 |
|
| 767 |
<a name="submit"></a> |
| 768 |
<h2>Submitting test results</h2> |
| 769 |
|
| 770 |
<p> |
| 771 |
To submit test results to our <a |
| 772 |
href="https://cdash.dealii.org/index.php?project=deal.II">CDash</a> |
| 773 |
instance just invoke ctest within a build directory (or designated |
| 774 |
build directory) with the <code>-S</code> option pointing to the |
| 775 |
<code>run_testsuite.cmake</code> script (assuming here for the |
| 776 |
moment that your build directory is a sub-directory of the |
| 777 |
source directory): |
| 778 |
<pre> |
| 779 |
$ ctest [...] -V -S ../tests/run_testsuite.cmake |
| 780 |
</pre> |
| 781 |
The script will run configure, build and ctest and submit the results |
| 782 |
to the CDash server. It does not matter whether the configure, build |
| 783 |
or ctest stages were run before that. Also in script mode, you can |
| 784 |
specify the same options for <code>ctest</code> as explained above. |
| 785 |
</p> |
| 786 |
|
| 787 |
<p> |
| 788 |
<b>Note:</b> |
| 789 |
For also building the tests in parallel you have to provide suitable flags |
| 790 |
using MAKEOPTS as well, i.e. you would typically use |
| 791 |
<pre> |
| 792 |
$ ctest -DMAKEOPTS="-j N" -j N [...] -V -S ../tests/run_testsuite.cmake |
| 793 |
</pre> |
| 794 |
for compiling the library and running the tests in parallel, |
| 795 |
where <code>N</code> is the number of jobs you want to |
| 796 |
simultaneously execute on your machine; you would typically |
| 797 |
choose <code>N</code> equal to the number of processor cores you |
| 798 |
have in your machine, or maybe somewhere around one half to |
| 799 |
three quarters if you don't want to overload it or are short on |
| 800 |
memory. |
| 801 |
</p> |
| 802 |
|
| 803 |
<p> |
| 804 |
It is possible to run tests and submit results for an already installed library by |
| 805 |
<pre> |
| 806 |
mkdir build && cd build |
| 807 |
cp $DEAL_II_SOURCE_DIR/CTestConfig.cmake . |
| 808 |
ctest \ |
| 809 |
-DCTEST_SOURCE_DIRECTORY=$DEAL_II_SOURCE_DIR/tests \ |
| 810 |
-DDEAL_II_DIR=$DEAL_II_DIR \ |
| 811 |
[...] -S $DEAL_II_SOURCE_DIR/tests/run_testsuite.cmake -V |
| 812 |
</pre> |
| 813 |
</p> |
| 814 |
|
| 815 |
<p> |
| 816 |
<b>Note:</b> The default output in script mode is very minimal. |
| 817 |
Therefore, it is recommended to specify <code>-V</code> which will |
| 818 |
give the same level of verbosity as the non-script mode. |
| 819 |
</p> |
| 820 |
|
| 821 |
<p> |
| 822 |
<b>Note:</b> The following variables can be set to via |
| 823 |
<pre> |
| 824 |
ctest -D<variable>=<value> [...] |
| 825 |
</pre> |
| 826 |
to control the behaviour of the <code>run_testsuite.cmake</code> |
| 827 |
script: |
| 828 |
<pre> |
| 829 |
CTEST_SOURCE_DIRECTORY |
| 830 |
- The source directory of deal.II |
| 831 |
- If unspecified, "../" relative to the location of this script is |
| 832 |
used. If this is not a source directory, an error is thrown. |
| 833 |
|
| 834 |
CTEST_BINARY_DIRECTORY |
| 835 |
- The designated build directory (already configured, empty, or non |
| 836 |
existent - see the information about TRACKs what will happen) |
| 837 |
- If unspecified the current directory is used. If the current |
| 838 |
directory is equal to CTEST_SOURCE_DIRECTORY or the "tests" |
| 839 |
directory, an error is thrown. |
| 840 |
|
| 841 |
CTEST_CMAKE_GENERATOR |
| 842 |
- The CMake Generator to use (e.g. "Unix Makefiles", or "Ninja", see |
| 843 |
$ man cmake) |
| 844 |
- If unspecified the generator of a configured build directory will |
| 845 |
be used, otherwise "Unix Makefiles". |
| 846 |
|
| 847 |
TRACK |
| 848 |
- The track the test should be submitted to. Defaults to |
| 849 |
"Experimental". Possible values are: |
| 850 |
|
| 851 |
"Experimental" - all tests that are not specifically "build" or |
| 852 |
"regression" tests should go into this track |
| 853 |
|
| 854 |
"Build Tests" - Build tests that configure and build in a clean |
| 855 |
directory (without actually running the |
| 856 |
testsuite) |
| 857 |
|
| 858 |
"Regression Tests" - Reserved for the "official" regression tester |
| 859 |
|
| 860 |
"Continuous" - Reserved for the "official" regression tester |
| 861 |
|
| 862 |
CONFIG_FILE |
| 863 |
- A configuration file (see doc/users/config.sample) |
| 864 |
that will be used during the configuration stage (invokes |
| 865 |
$ cmake -C ${CONFIG_FILE}). This only has an effect if |
| 866 |
CTEST_BINARY_DIRECTORY is empty. |
| 867 |
|
| 868 |
DESCRIPTION |
| 869 |
- A string that is appended to CTEST_BUILD_NAME |
| 870 |
|
| 871 |
COVERAGE |
| 872 |
- If set to ON deal.II will be configured with |
| 873 |
DEAL_II_SETUP_COVERAGE=ON, CMAKE_BUILD_TYPE=Debug and the |
| 874 |
CTEST_COVERAGE() stage will be run. Test results must go into the |
| 875 |
"Experimental" section. |
| 876 |
|
| 877 |
MAKEOPTS |
| 878 |
- Additional options that will be passed directly to make (or ninja). |
| 879 |
</pre> |
| 880 |
|
| 881 |
Furthermore, the variables TEST_TIME_LIMIT, TEST_MPI_RANK_LIMIT, |
| 882 |
TEST_THREAD_LIMIT and TEST_PICKUP_REGEX (as |
| 883 |
described <a href="#setupbuild">above</a>), DIFF_DIR, and NUMDIFF_DIR |
| 884 |
can also be set and will be handed automatically down |
| 885 |
to <code>cmake</code>. For more details on the different tracks, see |
| 886 |
the <a href="https://github.com/dealii/dealii/wiki/Testing-Infrastructure"> |
| 887 |
Testing Infrastructure Wiki page</a>. |
| 888 |
</p> |
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
<a name="build_tests"></a> |
| 893 |
<h2>Build tests</h2> |
| 894 |
|
| 895 |
<p> |
| 896 |
Build tests are used to check that deal.II can be compiled on |
| 897 |
different systems and with different compilers as well as |
| 898 |
different configuration options. Results are collected in the "Build |
| 899 |
Tests" track in <a |
| 900 |
href="https://cdash.dealii.org/index.php?project=deal.II">CDash</a>.<p> |
| 901 |
|
| 902 |
<p>Running the build test suite is simple and we encourage deal.II |
| 903 |
users with configurations not found on the <a |
| 904 |
href="https://cdash.dealii.org/index.php?project=deal.II">CDash page</a> to |
| 905 |
participate. Assuming you checked out deal.II into the directory |
| 906 |
<code>dealii</code>, running it is as simple as: |
| 907 |
<pre> |
| 908 |
mkdir dealii/build |
| 909 |
cd dealii/build |
| 910 |
ctest -j4 -S ../tests/run_buildtest.cmake |
| 911 |
</pre> |
| 912 |
</p> |
| 913 |
|
| 914 |
<p> |
| 915 |
What this does is to compile and build deal.II in the directory |
| 916 |
<code>build</code> (which includes building all configurable tutorial |
| 917 |
programs as well) but does not run the full testsuite. The results |
| 918 |
are sent to the CDash instance. |
| 919 |
</p> |
| 920 |
|
| 921 |
<p> |
| 922 |
<b>Note:</b> Build tests require the designated build directory to be |
| 923 |
completely empty. If you want to specify a build configuration for |
| 924 |
cmake use a <a href="../users/config.sample">configuration file</a> |
| 925 |
to preseed the cache as explained <a href="#submit">above</a>: |
| 926 |
<pre> |
| 927 |
$ ctest -DCONFIG_FILE="[...]/config.sample" [...] |
| 928 |
</pre> |
| 929 |
</p> |
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
<a name="dedicatedbuilds"></a> |
| 934 |
<h3>Dedicated build tests</h3> |
| 935 |
|
| 936 |
<p> |
| 937 |
Build tests work best if they run automatically and periodically. |
| 938 |
There is a detailed example for such dedicated build tests on the <a |
| 939 |
href="https://github.com/dealii/dealii/wiki/Build-Tests">wiki</a>. |
| 940 |
</p> |
| 941 |
|
| 942 |
|
| 943 |
<hr /> |
| 944 |
<div class="right"> |
| 945 |
<a href="https://validator.w3.org/check?uri=referer" target="_top"> |
| 946 |
<img style="border:0" src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a> |
| 947 |
<a href="https://jigsaw.w3.org/css-validator/check/referer" target="_top"> |
| 948 |
<img style="border:0;width:88px;height:31px" src="https://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a> |
| 949 |
</div> |
| 950 |
|
| 951 |
</body> |
| 952 |
</html> |