FSTests Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] generic/495: split the test
@ 2021-04-20 22:30 Pavel Reichl
  2021-04-21 16:19 ` Brian Foster
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Reichl @ 2021-04-20 22:30 UTC (permalink / raw)
  To: fstests

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>
---
 tests/generic/495     | 14 ++----------
 tests/generic/495.out |  3 ---
 tests/generic/634     | 50 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/634.out |  2 ++
 tests/generic/group   |  1 +
 5 files changed, 55 insertions(+), 15 deletions(-)
 create mode 100755 tests/generic/634
 create mode 100644 tests/generic/634.out

diff --git a/tests/generic/495 b/tests/generic/495
index 79a8abb3..f1a8a619 100755
--- a/tests/generic/495
+++ b/tests/generic/495
@@ -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
diff --git a/tests/generic/495.out b/tests/generic/495.out
index a7e3b720..16de8245 100644
--- a/tests/generic/495.out
+++ b/tests/generic/495.out
@@ -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/634 b/tests/generic/634
new file mode 100755
index 00000000..069d9f0e
--- /dev/null
+++ b/tests/generic/634
@@ -0,0 +1,50 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Facebook. All Rights Reserved.
+#
+# FS QA Test 634
+#
+# 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
+
+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
diff --git a/tests/generic/634.out b/tests/generic/634.out
new file mode 100644
index 00000000..b90e5758
--- /dev/null
+++ b/tests/generic/634.out
@@ -0,0 +1,2 @@
+QA output created by 634
+swapon: Invalid argument
diff --git a/tests/generic/group b/tests/generic/group
index 033465f1..158d759b 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -636,3 +636,4 @@
 631 auto rw overlay rename
 632 auto quick mount
 633 auto quick atime attr cap idmapped io_uring mount perms rw unlink
+634 auto quick swap
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] generic/495: split the test
  2021-04-20 22:30 [PATCH] generic/495: split the test Pavel Reichl
@ 2021-04-21 16:19 ` Brian Foster
  2021-04-23 10:10   ` Pavel Reichl
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Foster @ 2021-04-21 16:19 UTC (permalink / raw)
  To: Pavel Reichl; +Cc: fstests

On Wed, Apr 21, 2021 at 12:30:44AM +0200, Pavel Reichl wrote:
> 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>
> ---
>  tests/generic/495     | 14 ++----------
>  tests/generic/495.out |  3 ---
>  tests/generic/634     | 50 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/634.out |  2 ++
>  tests/generic/group   |  1 +
>  5 files changed, 55 insertions(+), 15 deletions(-)
>  create mode 100755 tests/generic/634
>  create mode 100644 tests/generic/634.out
> 
...
> diff --git a/tests/generic/634 b/tests/generic/634
> new file mode 100755
> index 00000000..069d9f0e
> --- /dev/null
> +++ b/tests/generic/634
> @@ -0,0 +1,50 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2018 Facebook. All Rights Reserved.
> +#
> +# FS QA Test 634
> +#
> +# 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
> +
> +rm -f "$SCRATCH_MNT/swap"

This looks spurious now that the fs is initially clean. Otherwise LGTM:

Reviewed-by: Brian Foster <bfoster@redhat.com>

> +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/634.out b/tests/generic/634.out
> new file mode 100644
> index 00000000..b90e5758
> --- /dev/null
> +++ b/tests/generic/634.out
> @@ -0,0 +1,2 @@
> +QA output created by 634
> +swapon: Invalid argument
> diff --git a/tests/generic/group b/tests/generic/group
> index 033465f1..158d759b 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -636,3 +636,4 @@
>  631 auto rw overlay rename
>  632 auto quick mount
>  633 auto quick atime attr cap idmapped io_uring mount perms rw unlink
> +634 auto quick swap
> -- 
> 2.30.2
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] generic/495: split the test
  2021-04-21 16:19 ` Brian Foster
@ 2021-04-23 10:10   ` Pavel Reichl
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Reichl @ 2021-04-23 10:10 UTC (permalink / raw)
  To: Brian Foster; +Cc: fstests

On 4/21/21 6:19 PM, Brian Foster wrote:
> On Wed, Apr 21, 2021 at 12:30:44AM +0200, Pavel Reichl wrote:
...
>> +
>> +rm -f "$SCRATCH_MNT/swap"
> 
> This looks spurious now that the fs is initially clean. Otherwise LGTM:
> 
> Reviewed-by: Brian Foster <bfoster@redhat.com>
> 

Hi Brian, thanks for the review - your comment was addressed in v2 of this patch, which is on the list already, thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 22:30 [PATCH] generic/495: split the test Pavel Reichl
2021-04-21 16:19 ` Brian Foster
2021-04-23 10:10   ` Pavel Reichl

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
		fstests@vger.kernel.org
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.fstests


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git