[LTP] [PATCH 2/6] lib: Add .max_runtime and tst_remaining_runtime()

Jan Stancek jstancek@redhat.com
Tue Oct 26 13:42:20 CEST 2021


On Mon, Oct 25, 2021 at 6:01 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> This is another attempt of decoupling test runtime from timeouts.
>
> Fundamentally there are two types of tests in LTP. First type are tests
> that are rather quick (much less than a second) and can live with
> whatever default timeout we set up. Second type of tests are tests that
> run in a loop until timeout or a number of iterations is reached, these
> are the tests that are going to be converted to the .max_runtime added
> by this patch and followups.
>
> This patch does:
>
> - adds .max_runtime to tst_test structure - this is the maximal runtime
>   per test iteration

I'm looking at the series, but I'm not sure I see much difference between
runtime and timeout. Other than some margin added by library (the MAX formula)
is there some other difference?

>
> - if .max_runtime is set
>   - test timeout is computed based on it and set as:
>     max_runtime + MAX(10, max_runtime)
>
>   - the -I option is mapped to the max runtime
>     this nicely unifies the test runtime command line option
>
> - replaces the tst_timeout_remining() whith tst_remaining_runtime() and
>   simplifies the code since we do no have to keep any margin for the
>   timeout, since we computed the timeout based on the runtime
>
> Side efect of this work is that all tests that use
> tst_remaining_runtime() must define it's runtime explicitelly which I
> think is step into the right direction as well.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---

<snip>

> diff --git a/testcases/kernel/syscalls/move_pages/move_pages12.c b/testcases/kernel/syscalls/move_pages/move_pages12.c
> index 220130f4b..e43bc5888 100644
> --- a/testcases/kernel/syscalls/move_pages/move_pages12.c
> +++ b/testcases/kernel/syscalls/move_pages/move_pages12.c
> @@ -153,7 +153,6 @@ static void do_test(unsigned int n)
>         void *ptr;
>         pid_t cpid = -1;
>         int status;
> -       unsigned int twenty_percent = (tst_timeout_remaining() / 5);
>
>         addr = SAFE_MMAP(NULL, tcases[n].tpages * hpsz, PROT_READ | PROT_WRITE,
>                 MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
> @@ -198,7 +197,7 @@ static void do_test(unsigned int n)
>
>                 SAFE_MUNMAP(addr, tcases[n].tpages * hpsz);
>
> -               if (tst_timeout_remaining() < twenty_percent)
> +               if (!tst_remaining_runtime())
>                         break;
>         }
>
> @@ -339,6 +338,7 @@ static struct tst_test test = {
>         .forks_child = 1,
>         .setup = setup,
>         .cleanup = cleanup,
> +       .max_runtime = 60,

Where does 60 come from?



More information about the ltp mailing list