diff mbox series

[ima-evm-utils,v4,08/11] Adapt fsverity.test to be able to run in a new testing environment

Message ID 20230126135807.1848668-9-roberto.sassu@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series Support testing in new enviroments | expand

Commit Message

Roberto Sassu Jan. 26, 2023, 1:58 p.m. UTC
From: Roberto Sassu <roberto.sassu@huawei.com>

Adapt fsverity.test by adding calls to the testing environment API in
functions.sh. If TST_ENV is set, create a new environment and run the
kernel specified with the TST_KERNEL environment variable. Otherwise, keep
the current behavior.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
---
 tests/fsverity.test | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tests/fsverity.test b/tests/fsverity.test
index be9594010de5..8261de4ea3c9 100755
--- a/tests/fsverity.test
+++ b/tests/fsverity.test
@@ -47,7 +47,7 @@  FSVERITY="$(which fsverity)"
 _require dd mkfs blkid e2fsck tune2fs evmctl setfattr
 ./gen-keys.sh >/dev/null 2>&1
 
-trap '_report_exit_and_cleanup cleanup' SIGINT SIGTERM EXIT
+trap '_report_exit_and_cleanup _cleanup_env cleanup' SIGINT SIGTERM EXIT
 
 cleanup() {
         if [ -e $TST_MNT ]; then
@@ -308,6 +308,15 @@  measure-ima() {
 	return "$error"
 }
 
+# Run in the new environment if TST_ENV is set.
+_run_env "$TST_KERNEL" "$PWD/$(basename "$0")" "TST_ENV=$TST_ENV TST_KERNEL=$TST_KERNEL PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH VERBOSE=$VERBOSE"
+
+# Exit from the creator of the new environment.
+_exit_env "$TST_KERNEL"
+
+# Mount filesystems in the new environment.
+_init_env
+
 # Dependency on being able to read and write the IMA policy file.
 # Requires both CONFIG_IMA_WRITE_POLICY, CONFIG_IMA_READ_POLICY be
 # enabled.