Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

libs/test/doc/testing_tools/timeout.qbk

[/
 / Copyright (c) 2015 Raffi Enficiaud
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]


[section:timeout Time-out for test cases]

The __UTF__ provides the decorator __decorator_timeout__ that specifies a time-out for a specific *test unit*.
The argument time is always expressed in *seconds ans wall-clock* time.

For test-cases, the time-out value sets the maximum allowed duration for the test. If this time is
exceeded, the test case is reported as failed. On some systems, the __UTF__ is able to force the test-case
to stop through a `SIGALRM` signal (see below).

For test-suites, the time-out value sets the maximum allowed duration for the entire suite to complete. This duration
is the accumulated time of all the test-cases contained in the sub-tree rooted on the test-suite, plus some extra
execution time needed by the __UTF__. For each test-units under a test-suite with time-out, the maximum allowed duration
is set as being the test-suite time out minus the accumulated execution time before the execution of the test-unit.
If this test-unit is a test-case, it is equivalent to setting the decorator __decorator_timeout__ to the test-case
with a time-out value expressed as before.

In case the test-suite times out, the
suite is flagged as `timed-out` and `failed`, and all the test units (suites and cases) that have not been executed
up to the time-out point are all skipped.

[bt_example decorator_11..decorator timeout..run-fail]

[note The macro
  `BOOST_SIGACTION_BASED_SIGNAL_HANDLING` is defined
  if Boost.Test is able to force the test-case to stop. This feature is for instance not supported on Windows.
  The __UTF__ will still be able to report the test-case as failed (once the test-case finishes).]

[note The support of test suite level time-out has been added in [link ref_CHANGE_LOG_3_10 Boost 1.70 / __UTF__ v3.10] ]

[endsect]