Skip to content

Commit

Permalink
test: use btrfs' mkswapfile on btrfs
Browse files Browse the repository at this point in the history
So it's created automagically with proper attributes.
  • Loading branch information
mrc0mmand committed Feb 17, 2024
1 parent e073c1d commit 1b0cf03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 1 addition & 3 deletions test/TEST-55-OOMD/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion test/units/testsuite-55.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b0cf03

Please sign in to comment.