Message ID | 20240117173006.31521-1-mdoucha@suse.cz |
---|---|
State | Accepted |
Headers | show |
Series | [1/2] Add tst_is_compat_mode() helper function | expand |
Hi Martin, > New helper function to simplify checks whether the test process runs > in e.g. 32bit compat mode on 64bit kernel. Reviewed-by: Petr Vorel <pvorel@suse.cz> ... > +int tst_is_compat_mode(void) > +{ > + return TST_ABI != tst_kernel_bits(); BTW setsockopt03.c and setsockopt08.c use: if (tst_kernel_bits() == 32 || sizeof(long) > 4) I guess they could also use tst_is_compat_mode(). And we have .skip_in_compat = 1, we could also add .require_compat (for documentation purposes. Kind regards, Petr
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) {
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(-)