diff mbox series

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

Message ID 20230125085030.1568256-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. 25, 2023, 8:50 a.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>
---
 tests/fsverity.test | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Stefan Berger Jan. 25, 2023, 10:45 p.m. UTC | #1
On 1/25/23 03:50, Roberto Sassu wrote:
> 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>
> ---
>   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.

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
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.