TEST-74-AUX-UTILS: Make more robust

Let's run mkfs on the file we create instead of the loop device and
let's use udevadm wait --settle to wait for udev to settle before
doing anything with the loop device

Fixes #32680 (hopefully)
This commit is contained in:
Daan De Meyer 2024-05-08 11:21:42 +02:00
parent b438ebd7bc
commit a35edc9ad4

View file

@ -32,8 +32,9 @@ systemd-mount --list --quiet
# Set up a simple block device for further tests
dd if=/dev/zero of="$WORK_DIR/simple.img" bs=1M count=16
mkfs.ext4 -L sd-mount-test "$WORK_DIR/simple.img"
LOOP="$(losetup --show --find "$WORK_DIR/simple.img")"
mkfs.ext4 -L sd-mount-test "$LOOP"
udevadm wait --timeout 60 --settle "$LOOP"
mkdir "$WORK_DIR/mnt"
mount "$LOOP" "$WORK_DIR/mnt"
touch "$WORK_DIR/mnt/foo.bar"
@ -130,8 +131,9 @@ systemd-umount "$WORK_DIR/simple.img"
# Create a vfat image, as ext4 doesn't support uid=/gid= fixating for all
# files/directories
dd if=/dev/zero of="$WORK_DIR/owner-vfat.img" bs=1M count=16
mkfs.vfat -n owner-vfat "$WORK_DIR/owner-vfat.img"
LOOP="$(losetup --show --find "$WORK_DIR/owner-vfat.img")"
mkfs.vfat -n owner-vfat "$LOOP"
udevadm wait --timeout 60 --settle "$LOOP"
# Mount it and check the UID/GID
[[ "$(stat -c "%U:%G" "$WORK_DIR/mnt")" == "root:root" ]]
systemd-mount --owner=testuser "$LOOP" "$WORK_DIR/mnt"