[LTP] [PATCH v2 1/1] lib: Multiply slow config only for a real tests

Li Wang liwang@redhat.com
Fri Jan 17 09:55:13 CET 2025


On Fri, Jan 17, 2025 at 4:41 PM Petr Vorel <pvorel@suse.cz> wrote:

> From: Petr Vorel <petr.vorel@gmail.com>
>
> Add a custom function which allows to avoid calling
> tst_has_slow_kconfig() function on testcases/lib/ tools, which use part
> of the API because they aren't tests.
>
> This fixes errors on shell tests on netns backend (the default):
>
>     # PATH="/opt/ltp/testcases/bin:$PATH" ping01.sh
>     ...
>     ping01 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
>     /opt/ltp/testcases/bin/ping01.sh: 142: [: tst_kconfig.c:88::
> unexpected operator
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     /opt/ltp/testcases/bin/ping01.sh: 142: [: tst_kconfig.c:88::
> unexpected operator
>     ping01 1 TINFO: add remote addr 10.0.0.1/24
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     /opt/ltp/testcases/bin/ping01.sh: 142: [: tst_kconfig.c:88::
> unexpected operator
>     ping01 1 TINFO: add remote addr fd00:1:1:1::1/64
>     tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
>     tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected
> which might slow the execution
>     /opt/ltp/testcases/bin/ping01.sh: 1: eval: tst_kconfig.c:88:: not found
>     /opt/ltp/testcases/bin/ping01.sh: 1: eval: 34mTINFO:: not found
>     /opt/ltp/testcases/bin/ping01.sh: 1: eval: 34mTINFO:: not found
>     /opt/ltp/testcases/bin/ping01.sh: 142: [: tst_kconfig.c:88::
> unexpected operator
>     /opt/ltp/testcases/bin/ping01.sh: 1: eval: tst_kconfig.c:88:: not found
>     /opt/ltp/testcases/bin/ping01.sh: 1: eval: 34mTINFO:: not found
>     /opt/ltp/testcases/bin/ping01.sh: 1: eval: 34mTINFO:: not found
>     ping01 1 TINFO: Network config (local -- remote):
>     ping01 1 TINFO: ltp_ns_veth2 -- ltp_ns_veth1
>     ping01 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24
>
> Fixes: 893ca0abe7 ("lib: multiply the timeout if detect slow kconfigs")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> NOTE: I'm not sure about the naming.
> This supersedes Li's patch
>
> https://patchwork.ozlabs.org/project/ltp/patch/20250117071758.120366-1-liwang@redhat.com/
>
> Other option is to add variable to struct tst_test as Li suggested.
>
> Kind regards,
> Petr
>
>  include/tst_test.h | 14 ++++++++++++++
>  lib/tst_test.c     |  3 +--
>  2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/include/tst_test.h b/include/tst_test.h
> index 5b3889e647..79bf6266e1 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -47,6 +47,7 @@
>  #include "tst_arch.h"
>  #include "tst_fd.h"
>  #include "tst_tmpdir.h"
> +#include "tst_kconfig.h"
>
>  void tst_res_(const char *file, const int lineno, int ttype,
>                const char *fmt, ...)
> @@ -725,8 +726,21 @@ int main(int argc, char *argv[])
>         tst_run_tcases(argc, argv, &test);
>  }
>
> +static inline int foo(unsigned int timeout)
>

What is the foo() used for?



> +{
> +       return timeout;
> +}
>  #endif /* TST_NO_DEFAULT_MAIN */
>
> +static inline int tst_multiply_on_slow_config(unsigned int timeout)
> +{
> +#ifndef TST_NO_DEFAULT_MAIN
> +       if (tst_has_slow_kconfig())
> +               timeout *= 4;
> +#endif /* TST_NO_DEFAULT_MAIN */
> +       return timeout;
> +}
>

But the tst_test.c has defined the TST_NO_DEFAULT_MAIN macro
so it will go complie with the second branch always.

IOW, the tst_has_slow_kconfig() will never be performed.



> +
>  /**
>   * TST_TEST_TCONF() - Exit tests with a TCONF message.
>   *
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index b204ad975f..6a43c0633e 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1702,8 +1702,7 @@ unsigned int tst_multiply_timeout(unsigned int
> timeout)
>         if (timeout < 1)
>                 tst_brk(TBROK, "timeout must to be >= 1! (%d)", timeout);
>
> -       if (tst_has_slow_kconfig())
> -               timeout *= 4;
> +       timeout = tst_multiply_on_slow_config(timeout);
>
>         return timeout * timeout_mul;
>  }
> --
> 2.47.1
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list