From: Roberto Sassu <roberto.sassu@xxxxxxxxxx> 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@xxxxxxxxxx> Reviewed-by: Stefan Berger <stefanb@xxxxxxxxxxxxx> --- tests/fsverity.test | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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. -- 2.25.1