[LTP] [PATCH] lib: do_setup(): Check for supported arch first

Cyril Hrubis chrubis@suse.cz
Tue Apr 29 15:55:42 CEST 2025


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



More information about the ltp mailing list