Skip to contentSkip to conversation

lib: add TST_NO_SLOW_KCONFIG_CHECK macro for testcase tools

PATCH In review Li Wang 3 participants 9 messages Jan 17, 2025 Library code

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 lib: add TST_NO_SLOW_KCONFIG_CHECK macro for testcase tools

The macro TST_NO_SLOW_KCONFIG_CHECK is added to control whether the tst_has_slow_kconfig() function (which presumably checks for slow kernel configurations) should be executed.

This allows test cases and tools to opt out of this additional check, enabling more flexible and faster test execution in certain scenarios.

---
 lib/tst_test.c                    | 2 ++
 testcases/lib/tst_device.c        | 1 +
 testcases/lib/tst_get_free_pids.c | 1 +
 testcases/lib/tst_ns_create.c     | 1 +
 testcases/lib/tst_ns_exec.c       | 1 +
 testcases/lib/tst_run_shell.c     | 1 +
 6 files changed, 7 insertions(+)
lib/tst_test.c +2 -0
index b204ad975..00d34b6f0 100644
@@ -1702,8 +1702,10 @@ unsigned int tst_multiply_timeout(unsigned int timeout)
 	if (timeout < 1)
 		tst_brk(TBROK, "timeout must to be >= 1! (%d)", timeout);
 
+#ifndef TST_NO_SLOW_KCONFIG_CHECK
 	if (tst_has_slow_kconfig())
 		timeout *= 4;
+#endif
 
 	return timeout * timeout_mul;
 }
testcases/lib/tst_device.c +1 -0
index 45f77a38b..386636610 100644
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 #include "tst_test.h"
 #include "old/old_device.h"
 
testcases/lib/tst_get_free_pids.c +1 -0
index 370ec3e26..c6436687a 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 #include <stdio.h>
 #include "tst_test.h"
 
testcases/lib/tst_ns_create.c +1 -0
index ce3707a60..8c22ad449 100644
@@ -17,6 +17,7 @@
  */
 
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 
 #include <stdio.h>
 #include <string.h>
testcases/lib/tst_ns_exec.c +1 -0
index 6a8e39339..ca5b717da 100644
@@ -14,6 +14,7 @@
  */
 
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 
 #include <stdio.h>
 #include <sys/wait.h>
testcases/lib/tst_run_shell.c +1 -0
index 7a446e004..b12a1e9f6 100644
@@ -5,6 +5,7 @@
 #include <sys/mount.h>
 
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 #include "tst_test.h"
 #include "tst_safe_stdio.h"
 #include "ujson.h"
Signature · 5 lines
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Li,

Quoted 3 lines

The macro TST_NO_SLOW_KCONFIG_CHECK is added to control whether the tst_has_slow_kconfig() function (which presumably checks for slow kernel configurations) should be executed.

That was quick, thanks a lot!

But unfortunately the patch does not help to avoid printing TINFO (tested on a fresh clone):

# make && ./tst_ns_exec 14536 net,mnt sh -c " cat /proc/sys/net/ipv6/conf/ltp_ns_veth1/disable_ipv6"
CC testcases/lib/tst_ns_exec
make[1]: Nothing to be done for 'all'.
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
0

Maybe it's because safe_clone() triggers it? Or what am I missing?

Kind regards,
Petr

Quoted 89 lines

This allows test cases and tools to opt out of this additional check, enabling more flexible and faster test execution in certain scenarios.

---
 lib/tst_test.c                    | 2 ++
 testcases/lib/tst_device.c        | 1 +
 testcases/lib/tst_get_free_pids.c | 1 +
 testcases/lib/tst_ns_create.c     | 1 +
 testcases/lib/tst_ns_exec.c       | 1 +
 testcases/lib/tst_run_shell.c     | 1 +
 6 files changed, 7 insertions(+)
lib/tst_test.c +2 -0
index b204ad975..00d34b6f0 100644
@@ -1702,8 +1702,10 @@ unsigned int tst_multiply_timeout(unsigned int timeout)
 	if (timeout < 1)
 		tst_brk(TBROK, "timeout must to be >= 1! (%d)", timeout);
 
+#ifndef TST_NO_SLOW_KCONFIG_CHECK
 	if (tst_has_slow_kconfig())
 		timeout *= 4;
+#endif
 
 	return timeout * timeout_mul;
 }
testcases/lib/tst_device.c +1 -0
index 45f77a38b..386636610 100644
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 #include "tst_test.h"
 #include "old/old_device.h"
 
testcases/lib/tst_get_free_pids.c +1 -0
index 370ec3e26..c6436687a 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 #include <stdio.h>
 #include "tst_test.h"
 
testcases/lib/tst_ns_create.c +1 -0
index ce3707a60..8c22ad449 100644
@@ -17,6 +17,7 @@
  */
 
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 
 #include <stdio.h>
 #include <string.h>
testcases/lib/tst_ns_exec.c +1 -0
index 6a8e39339..ca5b717da 100644
@@ -14,6 +14,7 @@
  */
 
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 
 #include <stdio.h>
 #include <sys/wait.h>
testcases/lib/tst_run_shell.c +1 -0
index 7a446e004..b12a1e9f6 100644
@@ -5,6 +5,7 @@
 #include <sys/mount.h>
 
 #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 #include "tst_test.h"
 #include "tst_safe_stdio.h"
 #include "ujson.h"
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Li,

Quoted 11 lines

Hi Li,

Quoted 3 lines

The macro TST_NO_SLOW_KCONFIG_CHECK is added to control whether the tst_has_slow_kconfig() function (which presumably checks for slow kernel configurations) should be executed.

That was quick, thanks a lot!

But unfortunately the patch does not help to avoid printing TINFO (tested on a fresh clone):

Quoted 8 lines
# make && ./tst_ns_exec 14536 net,mnt sh -c " cat /proc/sys/net/ipv6/conf/ltp_ns_veth1/disable_ipv6"
CC testcases/lib/tst_ns_exec
make[1]: Nothing to be done for 'all'.
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
0

Maybe it's because safe_clone() triggers it? Or what am I missing?

The problem why it does not work is that it uses lib/tst_test.o via lib/libltp.a, which was compiled without TST_NO_SLOW_KCONFIG_CHECK.

IMHO We cannot easily solve this with preprocessor definition.

Kind regards,
Petr

Quoted 6 lines

Kind regards,
Petr

Quoted 3 lines

This allows test cases and tools to opt out of this additional check, enabling more flexible and faster test execution in certain scenarios.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw
Quoted 19 lines · Petr Vorel

Hi Li,

Quoted 6 lines

Hi Li,

Quoted 3 lines

The macro TST_NO_SLOW_KCONFIG_CHECK is added to control whether the tst_has_slow_kconfig() function (which presumably checks for slow kernel configurations) should be executed.

Quoted 6 lines

That was quick, thanks a lot!

But unfortunately the patch does not help to avoid printing TINFO (tested on a fresh clone):

# make && ./tst_ns_exec 14536 net,mnt sh -c " cat

/proc/sys/net/ipv6/conf/ltp_ns_veth1/disable_ipv6"

Quoted 4 lines

CC testcases/lib/tst_ns_exec
make[1]: Nothing to be done for 'all'.
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz' tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which

Quoted 8 lines

might slow the execution

Quoted 3 lines

0

Maybe it's because safe_clone() triggers it? Or what am I missing?

The problem why it does not work is that it uses lib/tst_test.o via lib/libltp.a, which was compiled without TST_NO_SLOW_KCONFIG_CHECK.

Really? How does that TST_NO_DEFAULT_MAIN work?
Reading the code...

Quoted 14 lines

IMHO We cannot easily solve this with preprocessor definition.

Kind regards,
Petr

Quoted 6 lines

Kind regards,
Petr

Quoted 3 lines

This allows test cases and tools to opt out of this additional check, enabling more flexible and faster test execution in certain scenarios.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
Quoted 24 lines · Petr Vorel
Quoted 22 lines

Hi Li,

Quoted 6 lines

Hi Li,

Quoted 3 lines

The macro TST_NO_SLOW_KCONFIG_CHECK is added to control whether the tst_has_slow_kconfig() function (which presumably checks for slow kernel configurations) should be executed.

Quoted 6 lines

That was quick, thanks a lot!

But unfortunately the patch does not help to avoid printing TINFO (tested on a fresh clone):

# make && ./tst_ns_exec 14536 net,mnt sh -c " cat

/proc/sys/net/ipv6/conf/ltp_ns_veth1/disable_ipv6"

Quoted 4 lines

CC testcases/lib/tst_ns_exec
make[1]: Nothing to be done for 'all'.
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

Quoted 1 line

0

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Maybe it's because safe_clone() triggers it? Or what am I missing?

The problem why it does not work is that it uses lib/tst_test.o via lib/libltp.a, which was compiled without TST_NO_SLOW_KCONFIG_CHECK.

Really? How does that TST_NO_DEFAULT_MAIN work?
Reading the code...

I guess the code which evaluates TST_NO_DEFAULT_MAIN must be in static inline function in tst_test.h header. Then it will work.

Kind regards,
Petr

Quoted 11 lines
Quoted 11 lines

IMHO We cannot easily solve this with preprocessor definition.

Kind regards,
Petr

Quoted 6 lines

Kind regards,
Petr

Quoted 3 lines

This allows test cases and tools to opt out of this additional check, enabling more flexible and faster test execution in certain scenarios.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw
Quoted 31 lines · Petr Vorel
Quoted 15 lines · Petr Vorel
Quoted 13 lines

Hi Li,

Quoted 10 lines

Hi Li,

Quoted 3 lines

The macro TST_NO_SLOW_KCONFIG_CHECK is added to control whether the tst_has_slow_kconfig() function (which presumably checks for slow kernel configurations) should be executed.

That was quick, thanks a lot!

But unfortunately the patch does not help to avoid printing TINFO (tested on a fresh clone):

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
# make && ./tst_ns_exec 14536 net,mnt sh -c " cat

/proc/sys/net/ipv6/conf/ltp_ns_veth1/disable_ipv6"

Quoted 4 lines

CC testcases/lib/tst_ns_exec
make[1]: Nothing to be done for 'all'. tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz' tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected

which

Quoted 7 lines
Quoted 7 lines

might slow the execution

Quoted 3 lines

0

Maybe it's because safe_clone() triggers it? Or what am I missing?

The problem why it does not work is that it uses lib/tst_test.o via lib/libltp.a, which was compiled without TST_NO_SLOW_KCONFIG_CHECK.

Quoted 7 lines
Quoted 2 lines

Really? How does that TST_NO_DEFAULT_MAIN work?
Reading the code...

I guess the code which evaluates TST_NO_DEFAULT_MAIN must be in static inline
function in tst_test.h header. Then it will work.

Seems not, the TST_NO_DEFAULT_MAIN is defined in tst_test.c directly, so base on that, all the TST_NO_* macros in testcase/lib/* is redundant.

That mislead us the correct way.

Quoted 17 lines

Kind regards,
Petr

Quoted 11 lines
Quoted 11 lines

IMHO We cannot easily solve this with preprocessor definition.

Kind regards,
Petr

Quoted 6 lines

Kind regards,
Petr

Quoted 3 lines

This allows test cases and tools to opt out of this additional check, enabling more flexible and faster test execution in certain scenarios.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw
In reply to Li Wang

Hi Li,

the feature is interesting, but I have the feeling this should be added to tst_test struct rather than using a flag at compile time. For example, by adding to tst_test a slow_kconfig attribute.

Andrea

Quoted 93 lines · Li Wang

The macro TST_NO_SLOW_KCONFIG_CHECK is added to control whether the tst_has_slow_kconfig() function (which presumably checks for slow kernel configurations) should be executed.

This allows test cases and tools to opt out of this additional check, enabling more flexible and faster test execution in certain scenarios.

---
  lib/tst_test.c                    | 2 ++
  testcases/lib/tst_device.c        | 1 +
  testcases/lib/tst_get_free_pids.c | 1 +
  testcases/lib/tst_ns_create.c     | 1 +
  testcases/lib/tst_ns_exec.c       | 1 +
  testcases/lib/tst_run_shell.c     | 1 +
  6 files changed, 7 insertions(+)
lib/tst_test.c +2 -0
index b204ad975..00d34b6f0 100644
@@ -1702,8 +1702,10 @@ unsigned int tst_multiply_timeout(unsigned int timeout)
  	if (timeout < 1)
  		tst_brk(TBROK, "timeout must to be >= 1! (%d)", timeout);
 
+#ifndef TST_NO_SLOW_KCONFIG_CHECK
  	if (tst_has_slow_kconfig())
  		timeout *= 4;
+#endif
 
  	return timeout * timeout_mul;
  }
testcases/lib/tst_device.c +1 -0
index 45f77a38b..386636610 100644
@@ -8,6 +8,7 @@
  #include <stdio.h>
  #include <stdlib.h>
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
  #include "tst_test.h"
  #include "old/old_device.h"
 
testcases/lib/tst_get_free_pids.c +1 -0
index 370ec3e26..c6436687a 100644
@@ -1,6 +1,7 @@
  // SPDX-License-Identifier: GPL-2.0-or-later
 
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
  #include <stdio.h>
  #include "tst_test.h"
 
testcases/lib/tst_ns_create.c +1 -0
index ce3707a60..8c22ad449 100644
@@ -17,6 +17,7 @@
   */
 
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 
  #include <stdio.h>
  #include <string.h>
testcases/lib/tst_ns_exec.c +1 -0
index 6a8e39339..ca5b717da 100644
@@ -14,6 +14,7 @@
   */
 
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 
  #include <stdio.h>
  #include <sys/wait.h>
testcases/lib/tst_run_shell.c +1 -0
index 7a446e004..b12a1e9f6 100644
@@ -5,6 +5,7 @@
  #include <sys/mount.h>
 
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
  #include "tst_test.h"
  #include "tst_safe_stdio.h"
  #include "ujson.h"
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#7 lore raw
Quoted 6 lines · Andrea Cervesato

Hi Li,

the feature is interesting, but I have the feeling this should be added to tst_test struct rather than using a flag at compile time. For example, by adding to tst_test a slow_kconfig attribute.

Thanks. But sounds a little bit unnecessary to add new field in tst_test struct.

What about using an global variable like tst_no_slow_kcofig_check ?

Quoted 103 lines

Andrea

lib/tst_test.c unsigned int tst_multiply_timeout(unsigned int

Quoted 23 lines · Li Wang

The macro TST_NO_SLOW_KCONFIG_CHECK is added to control whether the tst_has_slow_kconfig() function (which presumably checks for slow kernel configurations) should be executed.

This allows test cases and tools to opt out of this additional check, enabling more flexible and faster test execution in certain scenarios.

---
  lib/tst_test.c                    | 2 ++
  testcases/lib/tst_device.c        | 1 +
  testcases/lib/tst_get_free_pids.c | 1 +
  testcases/lib/tst_ns_create.c     | 1 +
  testcases/lib/tst_ns_exec.c       | 1 +
  testcases/lib/tst_run_shell.c     | 1 +
  6 files changed, 7 insertions(+)
lib/tst_test.c +0 -0
index b204ad975..00d34b6f0 100644
@@ -1702,8 +1702,10 @@ unsigned int tst_multiply_timeout(unsigned int

timeout)

Review

Quoted 23 lines
lib/tst_test.c +2 -0
      if (timeout < 1)
              tst_brk(TBROK, "timeout must to be >= 1! (%d)", timeout);
 
+#ifndef TST_NO_SLOW_KCONFIG_CHECK
      if (tst_has_slow_kconfig())
              timeout *= 4;
+#endif
 
      return timeout * timeout_mul;
  }
testcases/lib/tst_device.c +1 -0
index 45f77a38b..386636610 100644
@@ -8,6 +8,7 @@
  #include <stdio.h>
  #include <stdlib.h>
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
  #include "tst_test.h"
  #include "old/old_device.h"
 
(quoted diff) +0 -0

b/testcases/lib/tst_get_free_pids.c

Review

Quoted 12 lines

index 370ec3e26..c6436687a 100644

testcases/lib/tst_get_free_pids.c +1 -0
@@ -1,6 +1,7 @@
  // SPDX-License-Identifier: GPL-2.0-or-later
 
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
  #include <stdio.h>
  #include "tst_test.h"
 
(quoted diff) +0 -0

b/testcases/lib/tst_ns_create.c

Review

Quoted 24 lines

index ce3707a60..8c22ad449 100644

testcases/lib/tst_ns_create.c +1 -0
@@ -17,6 +17,7 @@
   */
 
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 
  #include <stdio.h>
  #include <string.h>
testcases/lib/tst_ns_exec.c +1 -0
index 6a8e39339..ca5b717da 100644
@@ -14,6 +14,7 @@
   */
 
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
 
  #include <stdio.h>
  #include <sys/wait.h>
(quoted diff) +0 -0

b/testcases/lib/tst_run_shell.c

Quoted 11 lines

index 7a446e004..b12a1e9f6 100644

testcases/lib/tst_run_shell.c +1 -0
@@ -5,6 +5,7 @@
  #include <sys/mount.h>
 
  #define TST_NO_DEFAULT_MAIN
+#define TST_NO_SLOW_KCONFIG_CHECK
  #include "tst_test.h"
  #include "tst_safe_stdio.h"
  #include "ujson.h"
Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Hi all,

Quoted 10 lines
Quoted 5 lines · Andrea Cervesato

Hi Li,

the feature is interesting, but I have the feeling this should be added to tst_test struct rather than using a flag at compile time. For example, by adding to tst_test a slow_kconfig attribute.

Quoted 4 lines

Thanks. But sounds a little bit unnecessary to add new field in tst_test struct.

What about using an global variable like tst_no_slow_kcofig_check ?

This could work.

I sent a patch which takes yet another option: static inline function which differs based on existing TST_NO_DEFAULT_MAIN. That keeps the functionality for tests only, avoid it for libraries.

Actually similar approach Li did, but moved to header (it cannot be in C file).

Kind regards,
Petr

Quoted 1 line
Quoted 1 line

Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp