generic/495: split the test
authorPavel Reichl <preichl@redhat.com>
Fri, 23 Apr 2021 10:07:31 +0000 (12:07 +0200)
committerEryu Guan <guaneryu@gmail.com>
Sun, 25 Apr 2021 08:11:42 +0000 (16:11 +0800)
Split each swap-file test into its own test. So on file-systems that
do not support e.g. sparse files (exfat) other swap-file tests can be
executed.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Tested-by: Shreeya Patel <shreeya.patel@collabora.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/495
tests/generic/495.out
tests/generic/636 [new file with mode: 0755]
tests/generic/636.out [new file with mode: 0644]
tests/generic/group

index 79a8abb..f1a8a61 100755 (executable)
@@ -4,7 +4,7 @@
 #
 # FS QA Test 495
 #
-# Test invalid swap files.
+# Test invalid swap file (with holes)
 #
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
@@ -32,11 +32,11 @@ _supported_fs generic
 _require_scratch_swapfile
 _require_test_program mkswap
 _require_test_program swapon
+_require_sparse_files
 
 _scratch_mkfs >> $seqres.full 2>&1
 _scratch_mount
 
-echo "File with holes"
 # We can't use _format_swapfile because we're using our custom mkswap and
 # swapon.
 touch "$SCRATCH_MNT/swap"
@@ -47,15 +47,5 @@ $XFS_IO_PROG -c "truncate $(($(get_page_size) * 10))" "$SCRATCH_MNT/swap"
 "$here/src/swapon" "$SCRATCH_MNT/swap"
 swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
 
-echo "Empty swap file (only swap header)"
-rm -f "$SCRATCH_MNT/swap"
-touch "$SCRATCH_MNT/swap"
-$CHATTR_PROG +C "$SCRATCH_MNT/swap" >> $seqres.full 2>&1
-chmod 0600 "$SCRATCH_MNT/swap"
-_pwrite_byte 0x61 0 $(get_page_size) "$SCRATCH_MNT/swap" >> $seqres.full
-"$here/src/mkswap" "$SCRATCH_MNT/swap"
-"$here/src/swapon" "$SCRATCH_MNT/swap"
-swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
-
 status=0
 exit
index a7e3b72..16de824 100644 (file)
@@ -1,5 +1,2 @@
 QA output created by 495
-File with holes
-swapon: Invalid argument
-Empty swap file (only swap header)
 swapon: Invalid argument
diff --git a/tests/generic/636 b/tests/generic/636
new file mode 100755 (executable)
index 0000000..2f17687
--- /dev/null
@@ -0,0 +1,49 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Facebook. All Rights Reserved.
+#
+# FS QA Test 636
+#
+# Test invalid swap files.
+# Empty swap file (only swap header)
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+_supported_fs generic
+_require_scratch_swapfile
+_require_test_program mkswap
+_require_test_program swapon
+
+_scratch_mkfs >> $seqres.full 2>&1
+_scratch_mount
+
+touch "$SCRATCH_MNT/swap"
+$CHATTR_PROG +C "$SCRATCH_MNT/swap" >> $seqres.full 2>&1
+chmod 0600 "$SCRATCH_MNT/swap"
+_pwrite_byte 0x61 0 $(get_page_size) "$SCRATCH_MNT/swap" >> $seqres.full
+"$here/src/mkswap" "$SCRATCH_MNT/swap"
+"$here/src/swapon" "$SCRATCH_MNT/swap"
+swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
+
+status=0
+exit
diff --git a/tests/generic/636.out b/tests/generic/636.out
new file mode 100644 (file)
index 0000000..d3d7f37
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 636
+swapon: Invalid argument
index 62fe745..105763c 100644 (file)
 633 auto quick atime attr cap idmapped io_uring mount perms rw unlink
 634 auto quick atime bigtime
 635 auto quick atime bigtime shutdown
+636 auto quick swap