2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +00:00

regression tests: make loop device size more generous

Depending on the system, copying echo to the loop device fails because the echo binary is too large.
Especially on systems that have echo be just a symlink to coreutils (e.g. busybox) 16k is just not enough.
2M seems fine on my system, but this might need yet a higher value depending on what coreutils other people actually run.
The actual loop device needs to be larger to properly fit the allocated file size. Testing shows 4M is sufficient, but this is basically arbitrary.

(cherry picked from commit 1cc2a3bd86c5b6642f483c1da8da48276d694eab)
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Grimmauld 2024-12-19 23:26:26 +01:00 committed by John Johansen
parent 54f1cf8dca
commit 73842b54f7

View File

@ -22,14 +22,14 @@ backing_file="$tmpdir/loop_file"
mount_target="$tmpdir/mount_target"
mkdir "${mount_target}"
fallocate -l 512K "${backing_file}"
fallocate -l 4M "${backing_file}"
mkfs.fat -F 32 "${backing_file}" > /dev/null 2> /dev/null
losetup -f "${backing_file}" || fatalerror 'Unable to set up a loop device'
loop_device="$(/sbin/losetup -n -O NAME -l -j "${backing_file}")"
mount --make-unbindable "${loop_device}" "${mount_target}"
fallocate -l 16K "${mount_target}/a_file"
fallocate -l 2M "${mount_target}/a_file"
# echo is also a builtin, making things a bit more complicated
cp "$(type -P echo)" "${mount_target}/echo"