tests: Fix tests to setup the XDG_RUNTIME_DIR variable when empty

https://github.com/containers/toolbox/pull/857

When the XDG_RUNTIME_DIR variable is empty toolbox is not able to
initialize the container correctly and fails to run.
This commit is contained in:
Oliver Gutierrez 2021-08-03 19:14:22 +01:00 committed by Ondřej Míchal
parent 09fb237727
commit 075b9a8d27
8 changed files with 18 additions and 0 deletions

View file

@ -4,6 +4,10 @@ load 'libs/bats-support/load'
load 'libs/bats-assert/load'
load 'libs/helpers.bash'
setup() {
check_xdg_runtime_dir
}
@test "help: Run command 'help'" {
run $TOOLBOX help

View file

@ -5,6 +5,7 @@ load 'libs/bats-assert/load'
load 'libs/helpers'
setup() {
check_xdg_runtime_dir
cleanup_containers
}

View file

@ -5,6 +5,7 @@ load 'libs/bats-assert/load'
load 'libs/helpers'
setup() {
check_xdg_runtime_dir
cleanup_all
}

View file

@ -5,6 +5,7 @@ load 'libs/bats-assert/load'
load 'libs/helpers'
setup() {
check_xdg_runtime_dir
cleanup_containers
}

View file

@ -5,6 +5,7 @@ load 'libs/bats-assert/load'
load 'libs/helpers'
setup() {
check_xdg_runtime_dir
cleanup_containers
}

View file

@ -5,6 +5,7 @@ load 'libs/bats-assert/load'
load 'libs/helpers'
setup() {
check_xdg_runtime_dir
cleanup_containers
}

View file

@ -5,6 +5,7 @@ load 'libs/bats-assert/load'
load 'libs/helpers'
setup() {
check_xdg_runtime_dir
cleanup_all
}

View file

@ -270,3 +270,11 @@ function get_system_version() {
echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1)
}
# Setup the XDG_RUNTIME_DIR variable if not set
function check_xdg_runtime_dir() {
if [[ -z "${XDG_RUNTIME_DIR}" ]]; then
export XDG_RUNTIME_DIR="/run/user/${UID}"
fi
}