mirror of
https://git.code.sf.net/p/linux-ima/ima-evm-utils
synced 2025-07-01 21:31:14 +02:00
Add support for creating a new testing environment in functions.sh
Add the new functions _run_env(), _exit_env(), _init_env() and _cleanup_env() to run the tests inside a new environment specified with the TST_ENV environment variable. A typical structure of a script with tests is: trap '_report_exit_and_cleanup _cleanup_env cleanup' \ SIGINT SIGTERM SIGSEGV EXIT cleanup() { <test cleanup> } <tests implementations> _run_env "$TST_KERNEL" "$PWD/$(basename "$0")" "env_var1=$env_var1 ..." _exit_env "$TST_KERNEL" _init_env <tests init> <tests call> If TST_ENV is not set or empty, don't create a new testing environment and perform the cleanup in the current environment. Don't create a new testing environment also if the script is already executed in a new environment, to avoid loops. Instead, for cleanup, do it in the new environment and skip it in the host environment (if the cleanup function is passed to _cleanup_env()). Signal to the creator of the environment failures of tests or of the script itself run in the new environment (if the exit code is 1 ($FAIL) or 99 ($HARDFAIL)) with an unclean shutdown of the system. Add haveged and systemd as dependencies for the tests in ci/fedora.sh, respectively for initializing the random number generator and for shutting down the system in the new environment. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:

committed by
Mimi Zohar

parent
03b5d159ca
commit
f106a9022d
@ -45,7 +45,9 @@ yum -y install \
|
||||
vim-common \
|
||||
wget \
|
||||
which \
|
||||
zstd
|
||||
zstd \
|
||||
haveged \
|
||||
systemd
|
||||
|
||||
yum -y install docbook5-style-xsl || true
|
||||
yum -y install swtpm || true
|
||||
|
Reference in New Issue
Block a user