@@ -1,10 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (c) Linux Test Project, 2018-2024
*/
#ifndef TST_KERNEL_H__
#define TST_KERNEL_H__
+#include <stdbool.h>
+
/**
* tst_kernel_bits() - Detect if running on 32bit or 64bit kernel.
*
@@ -23,6 +26,16 @@ int tst_kernel_bits(void);
*/
int tst_is_compat_mode(void);
+/**
+ * tst_is_32bit() - Detect if compiled for 32bit target.
+ *
+ * Detect if compiled for 32bit target (regardless if the test process is
+ * running on 32bit or 64bit kernel).
+ *
+ * Return: true if compiled for 32bit target or false otherwise.
+ */
+bool tst_is_32bit(void);
+
/**
* tst_check_builtin_driver() - Check if the kernel module is built-in.
*
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (c) 2015-2016 Cyril Hrubis <chrubis@suse.cz>
- * Copyright (c) Linux Test Project, 2016-2019
+ * Copyright (c) Linux Test Project, 2016-2024
*/
#ifndef TST_TEST_H__
@@ -328,6 +328,9 @@ struct tst_ulimit_val {
* @skip_in_compat: Skip the test if we are executing 32bit binary on a 64bit
* kernel, i.e. we are testing the kernel compat layer.
*
+ * @skip_in_32bit: Skip the test if compiled for 32bit target (regardless if
+ * the test process is running on 32bit or 64bit kernel).
+ *
* @needs_hugetlbfs: If set hugetlbfs is mounted at tst_test.mntpoint.
*
* @skip_filesystems: A NULL terminated array of unsupported file systems. The
@@ -494,6 +497,7 @@ struct tst_ulimit_val {
unsigned int skip_in_lockdown:1;
unsigned int skip_in_secureboot:1;
unsigned int skip_in_compat:1;
+ unsigned int skip_in_32bit:1;
unsigned int needs_hugetlbfs:1;
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
* Copyright (c) 2020-2021 Petr Vorel <pvorel@suse.cz>
+ * Copyright (c) Linux Test Project, 2017-2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,6 +19,7 @@
#include <sys/personality.h>
#include <sys/utsname.h>
+#include <stdbool.h>
#include <limits.h>
#include "test.h"
@@ -96,6 +98,15 @@ int tst_is_compat_mode(void)
return TST_ABI != tst_kernel_bits();
}
+bool tst_is_32bit(void)
+{
+#ifdef TST_ABI32
+ return true;
+#else
+ return false;
+#endif
+}
+
static int tst_search_driver_(const char *driver, const char *file)
{
struct stat st;
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2015-2016 Cyril Hrubis <chrubis@suse.cz>
- * Copyright (c) Linux Test Project, 2016-2021
+ * Copyright (c) Linux Test Project, 2016-2024
*/
#include <limits.h>
@@ -1209,6 +1209,9 @@ static void do_setup(int argc, char *argv[])
if (tst_test->skip_in_compat && tst_is_compat_mode())
tst_brk(TCONF, "Not supported in 32-bit compat mode");
+ if (tst_test->skip_in_32bit && tst_is_32bit())
+ tst_brk(TCONF, "Not supported in 32-bit");
+
if (tst_test->needs_cmds) {
const char *cmd;
int i;
Signed-off-by: Petr Vorel <pvorel@suse.cz> --- include/tst_kernel.h | 13 +++++++++++++ include/tst_test.h | 6 +++++- lib/tst_kernel.c | 11 +++++++++++ lib/tst_test.c | 5 ++++- 4 files changed, 33 insertions(+), 2 deletions(-)