shell: Add TST_SKIP_IN_{LOCKDOWN,SECUREBOOT}=1
cover shell: Add TST_SKIP_IN_{LOCKDOWN,SECUREBOOT}=1
and use it in insmod01.sh.
Petr Vorel (4):
lib: shell: Add TST_SKIP_IN_LOCKDOWN=1
lib: shell: Add TST_SKIP_IN_SECUREBOOT=1 insmod01.sh: Skip test on lockdown and secure boot doc/shell-API: Document TST_SKIP_IN_{LOCKDOWN,SECUREBOOT}=1
doc/shell-test-api.txt | 5 +++++ doc/test-writing-guidelines.txt | 4 ++-- testcases/commands/insmod/insmod01.sh | 3 +++ testcases/lib/.gitignore | 2 ++ testcases/lib/Makefile | 2 +- testcases/lib/tst_lockdown_enabled.c | 12 ++++++++++++ testcases/lib/tst_secureboot_enabled.c | 12 ++++++++++++ testcases/lib/tst_test.sh | 10 +++++++++- 8 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 testcases/lib/tst_lockdown_enabled.c create mode 100644 testcases/lib/tst_secureboot_enabled.c
Signature · 5 lines
2.41.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/4 lib: shell: Add TST_SKIP_IN_LOCKDOWN=1
And tst_lockdown_enabled.c helper.
Detection is needed for insmod01.sh.
--- 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
doc/test-writing-guidelines.txt +1 -1
@@ -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' | –
testcases/lib/.gitignore +1 -0
@@ -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
testcases/lib/Makefile +1 -1
@@ -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
testcases/lib/tst_lockdown_enabled.c new file +12 -0
@@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2023 Petr Vorel <[email protected]> +*/ + +#define TST_NO_DEFAULT_MAIN +#include "tst_test.h" + +int main (void ) +{ +return !tst_lockdown_enabled (); +}
testcases/lib/tst_test.sh +5 -1
@@ -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
Signature · 5 lines
2.41.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/4 lib: shell: Add TST_SKIP_IN_SECUREBOOT=1
In reply to Petr VorelAnd tst_secureboot_enabled.c helper.
Detection is needed for insmod01.sh.
--- doc/test-writing-guidelines.txt | 2 +- testcases/lib/.gitignore | 1 + testcases/lib/Makefile | 2 +- testcases/lib/tst_secureboot_enabled.c | 12 ++++++++++++ testcases/lib/tst_test.sh | 6 +++++- 5 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 testcases/lib/tst_secureboot_enabled.c
doc/test-writing-guidelines.txt +1 -1
@@ -393,7 +393,7 @@ https://github.com/linux-test-project/ltp/wiki/Shell-Test-API[Shell Test API]. | '.skip_filesystems' | 'TST_SKIP_FILESYSTEMS' | '.skip_in_compat' | – | '.skip_in_lockdown' | 'TST_SKIP_IN_LOCKDOWN' -| '.skip_in_secureboot' | – +| '.skip_in_secureboot' | 'TST_SKIP_IN_SECUREBOOT' | '.supported_archs' | not applicable | '.tags' | – | '.taint_check' | –
testcases/lib/.gitignore +1 -0
@@ -19,6 +19,7 @@ /tst_ns_ifmove /tst_random /tst_rod +/tst_secureboot_enabled /tst_sleep /tst_supported_fs /tst_timeout_kill
testcases/lib/Makefile +1 -1
@@ -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_lockdown_enabled + tst_ns_ifmove tst_lockdown_enabled tst_secureboot_enabled include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/lib/tst_secureboot_enabled.c new file +12 -0
@@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2023 Petr Vorel <[email protected]> +*/ + +#define TST_NO_DEFAULT_MAIN +#include "tst_test.h" + +int main (void ) +{ +return !tst_secureboot_enabled (); +}
testcases/lib/tst_test.sh +5 -1
@@ -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_IN_LOCKDOWN);; + SKIP_FILESYSTEMS|SKIP_IN_LOCKDOWN|SKIP_IN_SECUREBOOT);; *) 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_SECUREBOOT" = 1 ] && tst_secureboot_enabled; then + tst_brk TCONF "SecureBoot enabled, skipping test" + fi + if [ "$TST_SKIP_IN_LOCKDOWN" = 1 ] && tst_lockdown_enabled; then tst_brk TCONF "Kernel is locked down, skipping test" fi
Signature · 5 lines
2.41.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/4 insmod01.sh: Skip test on lockdown and secure boot
In reply to Petr VorelLockdown patchset and secure boot does not allow to install LTP kernel module:
insmod: ERROR: could not insert module ltp_insmod01.ko: Operation not permitted insmod01 1 TFAIL: insmod failed
Therefore skip the test on them (similar to C tests in 56660bd61).
--- testcases/commands/insmod/insmod01.sh | 3 +++ 1 file changed, 3 insertions(+)
testcases/commands/insmod/insmod01.sh +3 -0
@@ -1,6 +1,7 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2016 Fujitsu Ltd. +# Copyright (c) Linux Test Project, 2016-2023 # Author: Guangwen Feng <[email protected]> # # Test basic functionality of insmod command.
@@ -10,6 +11,8 @@ TST_TESTFUNC=do_test TST_NEEDS_ROOT=1 TST_NEEDS_CMDS="rmmod insmod" TST_NEEDS_MODULE="ltp_insmod01.ko" +TST_SKIP_IN_LOCKDOWN=1 +TST_SKIP_IN_SECUREBOOT=1 inserted=0
Signature · 5 lines
2.41.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/4 doc/shell-API: Document TST_SKIP_IN_{LOCKDOWN, SECUREBOOT}=1
In reply to Petr Vorel--- doc/shell-test-api.txt | 5 +++++ 1 file changed, 5 insertions(+)
doc/shell-test-api.txt +5 -0
@@ -821,3 +821,8 @@ TST_NEEDS_KCONFIGS="CONFIG_EXT4_FS, CONFIG_QUOTACTL=y" . tst_test.sh ------------------------------------------------------------------------------- + +1.8 Skipping test based on system state +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Test can be skipped on various conditions: on enabled SecureBoot +('TST_SKIP_IN_SECUREBOOT=1'), lockdown ('TST_SKIP_IN_LOCKDOWN=1').
Signature · 5 lines
2.41.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 4/4] doc/shell-API: Document TST_SKIP_IN_{LOCKDOWN, SECUREBOOT}=1
Hi,
for the whole patchset:
Quoted 18 lines · Petr Vorel
Signed-off-by Petr Vorel <[email protected]>--- doc/shell-test-api.txt | 5 +++++ 1 file changed, 5 insertions(+)doc/shell-test-api.txt +5
-0@@ -821,3 +821,8 @@ TST_NEEDS_KCONFIGS="CONFIG_EXT4_FS, CONFIG_QUOTACTL=y" . tst_test.sh ------------------------------------------------------------------------------- + +1.8 Skipping test based on system state +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Test can be skipped on various conditions: on enabled SecureBoot +('TST_SKIP_IN_SECUREBOOT=1'), lockdown ('TST_SKIP_IN_LOCKDOWN=1').
Signature · 11 lines
Martin Doucha [email protected] SW Quality Engineer SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 0/4] shell: Add TST_SKIP_IN_{LOCKDOWN, SECUREBOOT}=1
In reply to Petr VorelHi!
Looks good.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 0/4] shell: Add TST_SKIP_IN_{LOCKDOWN, SECUREBOOT}=1
Hi Cyril,
Quoted 4 lines
Hi!
Looks good.Reviewed-by Cyril Hrubis <[email protected]>
Thank you for your review. Unless anybody complains, I'll merge this tonight.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 0/4] shell: Add TST_SKIP_IN_{LOCKDOWN, SECUREBOOT}=1
In reply to Petr VorelFor patches:
Quoted 28 lines · Petr Vorel
and use it in
insmod01.sh.Petr Vorel (4):
lib: shell: Add TST_SKIP_IN_LOCKDOWN=1
lib: shell: Add TST_SKIP_IN_SECUREBOOT=1insmod01.sh: Skip test on lockdown and secure boot doc/shell-API: Document TST_SKIP_IN_{LOCKDOWN,SECUREBOOT}=1doc/shell-test-api.txt | 5 +++++ doc/test-writing-guidelines.txt | 4 ++-- testcases/commands/insmod/insmod01.sh | 3 +++ testcases/lib/.gitignore | 2 ++ testcases/lib/Makefile | 2 +- testcases/lib/tst_lockdown_enabled.c | 12 ++++++++++++ testcases/lib/tst_secureboot_enabled.c | 12 ++++++++++++ testcases/lib/tst_test.sh | 10 +++++++++- 8 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 testcases/lib/tst_lockdown_enabled.c create mode 100644 testcases/lib/tst_secureboot_enabled.c--
2.41.0--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 0/4] shell: Add TST_SKIP_IN_{LOCKDOWN, SECUREBOOT}=1
Hi all,
thanks for your review, patchset merged.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp