All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] Add tst_is_compat_mode() helper function
@ 2024-01-17 17:30 Martin Doucha
  2024-01-17 17:30 ` [LTP] [PATCH 2/2] Add test for ASLRn't bug Martin Doucha
  2024-01-30 10:30 ` [LTP] [PATCH 1/2] Add tst_is_compat_mode() helper function Petr Vorel
  0 siblings, 2 replies; 9+ messages in thread
From: Martin Doucha @ 2024-01-17 17:30 UTC (permalink / raw)
  To: ltp

New helper function to simplify checks whether the test process runs
in e.g. 32bit compat mode on 64bit kernel.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 include/tst_kernel.h | 5 +++++
 lib/tst_kernel.c     | 6 ++++++
 lib/tst_test.c       | 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/tst_kernel.h b/include/tst_kernel.h
index 9d3a8d315..89de79928 100644
--- a/include/tst_kernel.h
+++ b/include/tst_kernel.h
@@ -10,6 +10,11 @@
  */
 int tst_kernel_bits(void);
 
+/*
+ * Returns non-zero if the test process is running in compat mode.
+ */
+int tst_is_compat_mode(void);
+
 /*
  * Checks if the kernel module is built-in.
  *
diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
index 51e4daa09..7fd1af871 100644
--- a/lib/tst_kernel.c
+++ b/lib/tst_kernel.c
@@ -23,6 +23,7 @@
 #include "test.h"
 #include "tst_kernel.h"
 #include "old_safe_stdio.h"
+#include "lapi/abisize.h"
 
 static int get_kernel_bits_from_uname(struct utsname *buf)
 {
@@ -90,6 +91,11 @@ int tst_kernel_bits(void)
 	return kernel_bits;
 }
 
+int tst_is_compat_mode(void)
+{
+	return TST_ABI != tst_kernel_bits();
+}
+
 static int tst_search_driver_(const char *driver, const char *file)
 {
 	struct stat st;
diff --git a/lib/tst_test.c b/lib/tst_test.c
index bcf2c4555..187358936 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1194,7 +1194,7 @@ static void do_setup(int argc, char *argv[])
 	if (tst_test->skip_in_secureboot && tst_secureboot_enabled() > 0)
 		tst_brk(TCONF, "SecureBoot enabled, skipping test");
 
-	if (tst_test->skip_in_compat && TST_ABI != tst_kernel_bits())
+	if (tst_test->skip_in_compat && tst_is_compat_mode())
 		tst_brk(TCONF, "Not supported in 32-bit compat mode");
 
 	if (tst_test->needs_cmds) {
-- 
2.42.1


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

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

end of thread, other threads:[~2024-01-30 16:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-17 17:30 [LTP] [PATCH 1/2] Add tst_is_compat_mode() helper function Martin Doucha
2024-01-17 17:30 ` [LTP] [PATCH 2/2] Add test for ASLRn't bug Martin Doucha
2024-01-30 11:29   ` Petr Vorel
2024-01-30 12:19     ` Martin Doucha
2024-01-30 12:31       ` Petr Vorel
2024-01-30 16:30   ` Petr Vorel
2024-01-30 16:32     ` Martin Doucha
2024-01-30 16:53       ` Petr Vorel
2024-01-30 10:30 ` [LTP] [PATCH 1/2] Add tst_is_compat_mode() helper function Petr Vorel

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.