mirror of
https://github.com/systemd/systemd
synced 2024-10-14 20:17:52 +00:00
test: create public images by default
Let's create new images public by default and then symlink/copy them into the respective private directories afterwards, not the other way around. This should fix a nasty race condition in parallel runs where one tests attempts to copy the backing public image at the same moment another test is already modifying it.
This commit is contained in:
parent
9554b8d1d1
commit
2991fa41e4
|
@ -678,6 +678,7 @@ cleanup_loopdev() {
|
|||
if [ -n "${LOOPDEV}" ]; then
|
||||
ddebug "losetup -d $LOOPDEV"
|
||||
losetup -d "${LOOPDEV}"
|
||||
unset LOOPDEV
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -698,8 +699,7 @@ create_empty_image() {
|
|||
rm -f "$IMAGE_PRIVATE" "$IMAGE_PUBLIC"
|
||||
|
||||
# Create the blank file to use as a root filesystem
|
||||
truncate -s "${_size}M" "$IMAGE_PRIVATE"
|
||||
ln -vs "$(realpath $IMAGE_PRIVATE)" "$IMAGE_PUBLIC"
|
||||
truncate -s "${_size}M" "$IMAGE_PUBLIC"
|
||||
|
||||
LOOPDEV=$(losetup --show -P -f "$IMAGE_PUBLIC")
|
||||
[ -b "$LOOPDEV" ] || return 1
|
||||
|
@ -2005,16 +2005,26 @@ test_setup() {
|
|||
if [ -e "$IMAGE_PRIVATE" ]; then
|
||||
echo "Reusing existing image $IMAGE_PRIVATE → $(realpath $IMAGE_PRIVATE)"
|
||||
mount_initdir
|
||||
elif [ -e "$IMAGE_PUBLIC" ]; then
|
||||
else
|
||||
if [ ! -e "$IMAGE_PUBLIC" ]; then
|
||||
# Create the backing public image, but then completely unmount
|
||||
# it and drop the loopback device responsible for it, since we're
|
||||
# going to symlink/copy the image and mount it again from
|
||||
# elsewhere.
|
||||
test_create_image
|
||||
test_setup_cleanup
|
||||
umount_loopback
|
||||
cleanup_loopdev
|
||||
fi
|
||||
|
||||
echo "Reusing existing cached image $IMAGE_PUBLIC → $(realpath $IMAGE_PUBLIC)"
|
||||
if [ ${TEST_PARALLELIZE} -ne 0 ]; then
|
||||
cp -v "$(realpath $IMAGE_PUBLIC)" "$IMAGE_PRIVATE"
|
||||
else
|
||||
ln -sv "$(realpath $IMAGE_PUBLIC)" "$IMAGE_PRIVATE"
|
||||
fi
|
||||
|
||||
mount_initdir
|
||||
else
|
||||
test_create_image
|
||||
fi
|
||||
|
||||
setup_nspawn_root
|
||||
|
|
Loading…
Reference in a new issue