diff --git a/test/test-functions b/test/test-functions index 0e795a904d..bdbc9fdd7c 100644 --- a/test/test-functions +++ b/test/test-functions @@ -959,7 +959,7 @@ install_fs_tools() { install_modules() { dinfo "Install modules" - instmods dummy vfat veth + instmods bridge dummy ipvlan macvlan vfat veth instmods loop =block instmods nls_ascii =nls instmods overlay =overlayfs diff --git a/test/units/testsuite-13.nspawn.sh b/test/units/testsuite-13.nspawn.sh index c449bda865..c01361999a 100755 --- a/test/units/testsuite-13.nspawn.sh +++ b/test/units/testsuite-13.nspawn.sh @@ -298,6 +298,154 @@ EOF (! systemd-nspawn --rlimit==) } +nspawn_settings_cleanup() { + for dev in sd-host-only sd-shared{1,2} sd-macvlan{1,2} sd-ipvlan{1,2}; do + ip link del "$dev" || : + done + + return 0 +} + +testcase_nspawn_settings() { + local root container dev private_users + + mkdir -p /run/systemd/nspawn + root="$(mktemp -d /var/lib/machines/testsuite-13.nspawn-settings.XXX)" + container="$(basename "$root")" + create_dummy_container "$root" + rm -f "/etc/systemd/nspawn/$container.nspawn" + mkdir -p "$root/tmp" "$root"/opt/{tmp,inaccessible,also-inaccessible} + + for dev in sd-host-only sd-shared{1,2} sd-macvlan{1,2} sd-ipvlan{1,2}; do + ip link add "$dev" type dummy + done + udevadm settle + ip link + trap nspawn_settings_cleanup RETURN + + # Let's start with one huge config to test as much as we can at once + cat >"/run/systemd/nspawn/$container.nspawn" <"$root/entrypoint.sh" <<\EOF +#!/bin/bash -ex + +[[ "$1" == "foo bar" ]] +[[ "$2" == "bar baz" ]] + +[[ "$USER" == root ]] +[[ "$FOO" == bar ]] +[[ "$BAZ" == "hello world" ]] +[[ "$PWD" == /tmp ]] +[[ "$("/run/systemd/nspawn/$container.nspawn" <