mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
test: mount overlayfs over /usr in some tests
Most of the integration tests have been made to not write to /usr but some genuinely need to do so. Because mkosi creates images with a read-only /usr it is not normally writeable. By mounting an overlayfs with /usr as the lower dir and upper and working dirs in /var tests may write to /usr.
This commit is contained in:
parent
0129395173
commit
8799346862
@ -5,6 +5,11 @@ set -o pipefail
|
||||
|
||||
# shellcheck source=test/units/test-control.sh
|
||||
. "$(dirname "$0")"/test-control.sh
|
||||
# shellcheck source=test/units/util.sh
|
||||
. "$(dirname "$0")"/util.sh
|
||||
|
||||
maybe_mount_usr_overlay
|
||||
trap 'maybe_umount_usr_overlay' EXIT
|
||||
|
||||
clear_unit() {
|
||||
local unit_name="${1:?}"
|
||||
|
@ -12,10 +12,13 @@ at_exit() {
|
||||
rm -fvr "/usr/lib/systemd/system/$UNIT_NAME" "/etc/systemd/system/$UNIT_NAME.d" "+4"
|
||||
fi
|
||||
|
||||
maybe_umount_usr_overlay
|
||||
|
||||
rm -f /etc/init.d/issue-24990
|
||||
return 0
|
||||
}
|
||||
|
||||
maybe_mount_usr_overlay
|
||||
trap at_exit EXIT
|
||||
|
||||
# Create a simple unit file for testing
|
||||
|
@ -6,6 +6,9 @@ set -o pipefail
|
||||
# shellcheck source=test/units/util.sh
|
||||
. "$(dirname "$0")"/util.sh
|
||||
|
||||
maybe_mount_usr_overlay
|
||||
trap 'maybe_umount_usr_overlay' EXIT
|
||||
|
||||
teardown_test_dependencies() (
|
||||
set +eux
|
||||
|
||||
|
@ -9,6 +9,9 @@ set -o pipefail
|
||||
# shellcheck source=test/units/util.sh
|
||||
. "$(dirname "$0")"/util.sh
|
||||
|
||||
maybe_mount_usr_overlay
|
||||
trap 'maybe_umount_usr_overlay' EXIT
|
||||
|
||||
enable_debug() {
|
||||
mkdir -p /run/systemd/system/systemd-localed.service.d
|
||||
cat >>/run/systemd/system/systemd-localed.service.d/override.conf <<EOF
|
||||
|
@ -216,3 +216,19 @@ kernel_supports_lsm() {
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
MOUNTED_USR_OVERLAY=false
|
||||
|
||||
maybe_mount_usr_overlay() {
|
||||
if [[ ! -w /usr ]]; then
|
||||
mkdir -p /tmp/usr-overlay/{upperdir,workdir}
|
||||
mount -t overlay -o lowerdir=/usr,upperdir=/tmp/usr-overlay/upperdir,workdir=/tmp/usr-overlay/workdir overlay /usr
|
||||
MOUNTED_USR_OVERLAY=true
|
||||
fi
|
||||
}
|
||||
|
||||
maybe_umount_usr_overlay() {
|
||||
if "$MOUNTED_USR_OVERLAY"; then
|
||||
umount -l /usr
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user