On 1/26/23 08:58, Roberto Sassu wrote:
From: Roberto Sassu <roberto.sassu@xxxxxxxxxx> 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@xxxxxxxxxx>
Reviewed-by: Stefan Berger <stefanb@xxxxxxxxxxxxx>