[LTP] [PATCH 1/4] lib: shell: Add TST_SKIP_IN_LOCKDOWN=1
Petr Vorel
pvorel@suse.cz
Fri Jul 28 15:21:14 CEST 2023
And tst_lockdown_enabled.c helper.
Detection is needed for insmod01.sh.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
doc/test-writing-guidelines.txt | 2 +-
testcases/lib/.gitignore | 1 +
testcases/lib/Makefile | 2 +-
testcases/lib/tst_lockdown_enabled.c | 12 ++++++++++++
testcases/lib/tst_test.sh | 6 +++++-
5 files changed, 20 insertions(+), 3 deletions(-)
create mode 100644 testcases/lib/tst_lockdown_enabled.c
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 6d1a69165..367fa780b 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -392,7 +392,7 @@ https://github.com/linux-test-project/ltp/wiki/Shell-Test-API[Shell Test API].
| '.setup' | 'TST_SETUP'
| '.skip_filesystems' | 'TST_SKIP_FILESYSTEMS'
| '.skip_in_compat' | –
-| '.skip_in_lockdown' | –
+| '.skip_in_lockdown' | 'TST_SKIP_IN_LOCKDOWN'
| '.skip_in_secureboot' | –
| '.supported_archs' | not applicable
| '.tags' | –
diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore
index a8573922d..b824767f7 100644
--- a/testcases/lib/.gitignore
+++ b/testcases/lib/.gitignore
@@ -10,6 +10,7 @@
/tst_get_unused_port
/tst_hexdump
/tst_kvcmp
+/tst_lockdown_enabled
/tst_net_iface_prefix
/tst_net_ip_prefix
/tst_net_vars
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
index 14728bf89..3094aa463 100644
--- a/testcases/lib/Makefile
+++ b/testcases/lib/Makefile
@@ -13,6 +13,6 @@ MAKE_TARGETS := tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\
tst_getconf tst_supported_fs tst_check_drivers tst_get_unused_port\
tst_get_median tst_hexdump tst_get_free_pids tst_timeout_kill\
tst_check_kconfigs tst_cgctl tst_fsfreeze tst_ns_create tst_ns_exec\
- tst_ns_ifmove
+ tst_ns_ifmove tst_lockdown_enabled
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/tst_lockdown_enabled.c b/testcases/lib/tst_lockdown_enabled.c
new file mode 100644
index 000000000..0e40c428c
--- /dev/null
+++ b/testcases/lib/tst_lockdown_enabled.c
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
+ */
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+int main(void)
+{
+ return !tst_lockdown_enabled();
+}
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 55133666d..afcf66b20 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -678,7 +678,7 @@ tst_run()
CHECKPOINT_WAIT|CHECKPOINT_WAKE);;
CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);;
DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);;
- SKIP_FILESYSTEMS);;
+ SKIP_FILESYSTEMS|SKIP_IN_LOCKDOWN);;
*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
esac
done
@@ -698,6 +698,10 @@ tst_run()
[ "$TST_NEEDS_ROOT" = 1 ] && tst_require_root
+ if [ "$TST_SKIP_IN_LOCKDOWN" = 1 ] && tst_lockdown_enabled; then
+ tst_brk TCONF "Kernel is locked down, skipping test"
+ fi
+
[ "$TST_DISABLE_APPARMOR" = 1 ] && tst_disable_apparmor
[ "$TST_DISABLE_SELINUX" = 1 ] && tst_disable_selinux
--
2.41.0
More information about the ltp
mailing list