[LTP] [PATCH v3 01/29] Introduce a concept of max runtime

Li Wang liwang@redhat.com
Sat May 14 06:21:08 CEST 2022


On Thu, May 12, 2022 at 8:36 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> This commit introduces a concept of max test runtime. In other words
> test runtime is capped at a certain value in order to make testruns more
> deterministic. Test is free to to finish before the runtime is used up,
> for example when maximal number of iterations was reached, but test must
> stop once the runtime has been used up.
>
> Testcases that run for more than a second or two must check for
> remaining runtime by regular calls to tst_remaining_runtime() and should
> exit when zero is returned.
>
> The test max runtime must be set either by the .max_iteration_runtime in
>

.max_runtime



> the tst_test structure or in the test setup by a call to
> tst_set_runtime().
>

tst_set_max_runtime()



>
> The test timeout is then computed as a sum of DEFAULT_TIMEOUT (currently
> set to 30 seconds) and the test runtime. The DEFAULT_TIMEOUT is nothing
> more than a safety margin for teardown of the test.
>
> This commit also maps the -I parameter to the test max runtime if
> available and introduces LTP_RUNTIME_MUL enviroment variable so that we
> have an easy controll over the runtime cap.
>
> Lastly but not least the function related to the timeout are turned into
> no-op by this commit and removed after all test are converted to the
> runtime API.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  doc/c-test-api.txt                       |  42 +++++--
>  doc/user-guide.txt                       |  30 ++++-
>  include/tst_test.h                       |  27 ++++
>  lib/newlib_tests/.gitignore              |   5 +-
>  lib/newlib_tests/runtest.sh              |   2 +-
>  lib/newlib_tests/test10.c                |  22 ----
>  lib/newlib_tests/test12.c                |  21 ----
>  lib/newlib_tests/test13.c                |   1 -
>  lib/newlib_tests/test18.c                |  22 ----
>  lib/newlib_tests/test_children_cleanup.c |   1 -
>  lib/newlib_tests/test_runtime01.c        |  30 +++++
>  lib/newlib_tests/test_runtime02.c        |  28 +++++
>  lib/tst_test.c                           | 150 +++++++++++++++++------
>  13 files changed, 264 insertions(+), 117 deletions(-)
>  delete mode 100644 lib/newlib_tests/test10.c
>  delete mode 100644 lib/newlib_tests/test12.c
>  delete mode 100644 lib/newlib_tests/test18.c
>  create mode 100644 lib/newlib_tests/test_runtime01.c
>  create mode 100644 lib/newlib_tests/test_runtime02.c
>
> diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt
> index 9f104ecd7..711b445d9 100644
> --- a/doc/c-test-api.txt
> +++ b/doc/c-test-api.txt
> @@ -93,14 +93,35 @@ in range of [0, '.tcnt' - 1].
>
>  IMPORTANT: Only one of '.test' and '.test_all' can be set at a time.
>
> -Each test has a default timeout set to 300s. The default timeout can be
> -overridden by setting '.timeout' in the test structure or by calling
> -'tst_set_timeout()' in the test 'setup()'. There are a few testcases
> whose run
> -time may vary arbitrarily, for these timeout can be disabled by setting
> it to
> --1.
> +Each test has a limit on how long it can run and the limit composes of two
> +parts max_runtime and timeout. The max_runtime is a limit for how long
> can the
> +'.test_all' or a set of '.test' functions take and the timeout is static
> part
> +that should cover the duration of test setup and cleanup plus some safety.
>
> -Test can find out how much time (in seconds) is remaining to timeout,
> -by calling 'tst_timeout_remaining()'.
> +Any test that runs for more than a second or two has to make sure to:
> +
> +- set the runtime either by setting the '.max_runtime' in tst_test or by
> +  calling 'tst_set_runtime()' in the test setup
>

     ^ calling 'tst_set_max_runtime()'

Apart from the patch-22 tiny issue, the rest part looks good.

Reviewed-by: Li Wang <liwang@redhat.com>


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20220514/66b1c254/attachment.htm>


More information about the ltp mailing list