test: use btrfs' mkswapfile on btrfs

So it's created automagically with proper attributes.
This commit is contained in:
Frantisek Sumsal 2024-02-14 11:48:56 +01:00
parent e073c1d8ed
commit 1b0cf03668
2 changed files with 9 additions and 4 deletions

View File

@ -15,9 +15,7 @@ test_append_files() {
# Create a swap file
(
image_install mkswap swapon swapoff stress
dd if=/dev/zero of="${initdir:?}/swapfile" bs=1M count=48
chmod 0600 "${initdir:?}/swapfile"
image_install -o btrfs
mkdir -p "${initdir:?}/etc/systemd/system/init.scope.d/"
cat >>"${initdir:?}/etc/systemd/system/init.scope.d/test-55-oomd.conf" <<EOF

View File

@ -23,7 +23,14 @@ rm -rf /run/systemd/system/testsuite-55-testbloat.service.d
# Activate swap file if we are in a VM
if systemd-detect-virt --vm --quiet; then
mkswap /swapfile
if [[ "$(findmnt -n -o FSTYPE /)" == btrfs ]]; then
btrfs filesystem mkswapfile -s 64M /swapfile
else
dd if=/dev/zero of=/swapfile bs=1M count=64
chmod 0600 /swapfile
mkswap /swapfile
fi
swapon /swapfile
swapon --show
fi