All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 1/1] lib: Multiply slow config only for a real tests
@ 2025-01-17  8:41 Petr Vorel
  2025-01-17  8:55 ` Li Wang
  2025-01-17  9:40 ` Cyril Hrubis
  0 siblings, 2 replies; 17+ messages in thread
From: Petr Vorel @ 2025-01-17  8:41 UTC (permalink / raw)
  To: ltp

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)
+{
+	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;
+}
+
 /**
  * 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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-01-17 12:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17  8:41 [LTP] [PATCH v2 1/1] lib: Multiply slow config only for a real tests Petr Vorel
2025-01-17  8:55 ` Li Wang
2025-01-17  9:16   ` Petr Vorel
2025-01-17  9:26     ` Li Wang
2025-01-17  9:34       ` Li Wang
2025-01-17  9:40 ` Cyril Hrubis
2025-01-17  9:57   ` Petr Vorel
2025-01-17 10:14     ` Cyril Hrubis
2025-01-17 10:28       ` Petr Vorel
2025-01-17 10:31         ` Cyril Hrubis
2025-01-17 10:51           ` Petr Vorel
2025-01-17 10:55           ` Petr Vorel
2025-01-17 10:18     ` Petr Vorel
2025-01-17 10:30       ` Cyril Hrubis
2025-01-17 11:47         ` Petr Vorel
2025-01-17 12:07           ` Cyril Hrubis
2025-01-17 12:21             ` Li Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.