2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle. All Rights Reserved.
7 # Test various swapfile activation oddities.
10 _begin_fstest auto quick swap
12 # Override the default cleanup function.
16 swapoff $swapfile 2> /dev/null
20 # Import common functions.
23 # real QA test starts here
25 _require_scratch_swapfile
26 _require_test_program mkswap
27 _require_test_program swapon
29 _scratch_mkfs >>$seqres.full 2>&1
30 _scratch_mount >>$seqres.full 2>&1
32 swapfile=$SCRATCH_MNT/swap
40 # Swap files must be nocow on Btrfs.
41 $CHATTR_PROG +C $swapfile >> $seqres.full 2>&1
42 _pwrite_byte 0x58 0 $len $swapfile >> $seqres.full
43 "$here/src/mkswap" $swapfile >> $seqres.full
44 "$here/src/swapon" $swapfile 2>&1 | _filter_scratch
45 swapoff $swapfile 2>> $seqres.full
49 # Create a regular swap file
50 echo "regular swap" | tee -a $seqres.full
51 swapfile_cycle $swapfile $len
53 # Create a swap file with a little too much junk on the end
54 echo "too long swap" | tee -a $seqres.full
55 swapfile_cycle $swapfile $((len + 3))
57 # Create a ridiculously small swap file. Each swap file must have at least
58 # two pages after the header page.
59 echo "tiny swap" | tee -a $seqres.full
60 swapfile_cycle $swapfile $(($(get_page_size) * 3))