All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib: do_setup(): Check for supported arch first
@ 2025-04-29 13:55 Cyril Hrubis
  2025-04-29 14:55 ` Andrea Cervesato via ltp
  2025-04-29 21:22 ` Petr Vorel
  0 siblings, 2 replies; 8+ messages in thread
From: Cyril Hrubis @ 2025-04-29 13:55 UTC (permalink / raw)
  To: ltp

This commit moves the check for supported architecture before the check
for test function existence. This allows us do ifdef out the run
function pointer initialization and properly TCONF on unsupported
platform.

Example usage:

 #include "tst_test.h"

 #ifdef __x86_64__
 static void run(void)
 {
	...
 }
 #endif

 struct tst_test test = {
 #ifdef __x86_64__
	.run = run,
 #endif
	.supported_archs = {"x86_64", NULL},
 }

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/tst_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 694861d95..c47ddd86a 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1273,6 +1273,9 @@ static void do_setup(int argc, char *argv[])
 	if (tst_test->tconf_msg)
 		tst_brk(TCONF, "%s", tst_test->tconf_msg);
 
+	if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
+		tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);
+
 	assert_test_fn();
 
 	TCID = tid = get_tid(argv);
@@ -1301,9 +1304,6 @@ static void do_setup(int argc, char *argv[])
 	if (tst_test->min_kver)
 		check_kver(tst_test->min_kver, 1);
 
-	if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
-		tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);
-
 	if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0)
 		tst_brk(TCONF, "Kernel is locked down, skipping test");
 
-- 
2.49.0


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

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

end of thread, other threads:[~2025-04-30  7:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-29 13:55 [LTP] [PATCH] lib: do_setup(): Check for supported arch first Cyril Hrubis
2025-04-29 14:55 ` Andrea Cervesato via ltp
2025-04-29 15:06   ` Cyril Hrubis
2025-04-29 15:17     ` Andrea Cervesato via ltp
2025-04-29 15:20       ` Cyril Hrubis
2025-04-29 15:29         ` Andrea Cervesato via ltp
2025-04-29 21:22 ` Petr Vorel
2025-04-30  7:14   ` Cyril Hrubis

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.