From: Frantisek Sumsal Date: Wed, 17 May 2023 20:36:07 +0000 (+0200) Subject: test: add a couple of tests for nspawn config files X-Git-Tag: v254-rc1~447^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbd20ab41bc908b976b80529c0f93b55c12b05b2;p=thirdparty%2Fsystemd.git test: add a couple of tests for nspawn config files --- diff --git a/test/test-functions b/test/test-functions index 0e795a904dd..bdbc9fdd7c8 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 c449bda865c..c01361999a0 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" <