From patchwork Mon Dec 3 06:42:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 10708661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDEF417D4 for ; Mon, 3 Dec 2018 06:43:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE0BB2AC61 for ; Mon, 3 Dec 2018 06:43:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C19522AC66; Mon, 3 Dec 2018 06:43:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62F672AC61 for ; Mon, 3 Dec 2018 06:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725891AbeLCGnK (ORCPT ); Mon, 3 Dec 2018 01:43:10 -0500 Received: from ipmail06.adl2.internode.on.net ([150.101.137.129]:5095 "EHLO ipmail06.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbeLCGnK (ORCPT ); Mon, 3 Dec 2018 01:43:10 -0500 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail06.adl2.internode.on.net with ESMTP; 03 Dec 2018 17:13:02 +1030 Received: from discord.disaster.area ([192.168.1.111]) by dastard with esmtp (Exim 4.80) (envelope-from ) id 1gThwZ-0003G4-2z for fstests@vger.kernel.org; Mon, 03 Dec 2018 17:42:59 +1100 Received: from dave by discord.disaster.area with local (Exim 4.91) (envelope-from ) id 1gThwZ-00075H-1x for fstests@vger.kernel.org; Mon, 03 Dec 2018 17:42:59 +1100 From: Dave Chinner To: fstests@vger.kernel.org Subject: [PATCH 1/3] common: add _require_test_swapfile Date: Mon, 3 Dec 2018 17:42:54 +1100 Message-Id: <20181203064256.26768-2-david@fromorbit.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203064256.26768-1-david@fromorbit.com> References: <20181203064256.26768-1-david@fromorbit.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Chinner Because we can host swap files on the test device, not just the scratch device. Also, move the tests for the utilities needed to manipulate swap files into the functions that test whether swap files are supported so they are checked for existence /before/ we try to us them. This fixes all the tests that currently check for these utilities manually /after/ checking if swapfiles are supported. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- common/rc | 29 +++++++++++++++++++++-------- tests/generic/472 | 2 -- tests/generic/495 | 2 -- tests/generic/496 | 2 -- tests/generic/497 | 2 -- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/common/rc b/common/rc index ecb17380bad8..5b344b25012b 100644 --- a/common/rc +++ b/common/rc @@ -2214,22 +2214,35 @@ _format_swapfile() { } # Check that the filesystem supports swapfiles -_require_scratch_swapfile() +_require_swapfile() { - _require_scratch + dir=$1 - _scratch_mkfs >/dev/null - _scratch_mount + # fstests also has custom binaries for mkswap/swapon + _require_test_program mkswap + _require_test_program swapon # Minimum size for mkswap is 10 pages - _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) + _format_swapfile "$dir/swap" $(($(get_page_size) * 10)) - if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then - _scratch_unmount + if ! swapon "$dir/swap" >/dev/null 2>&1; then _notrun "swapfiles are not supported" fi - swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1 + swapoff "$dir/swap" >/dev/null 2>&1 +} + +_require_test_swapfile() +{ + _require_swapfile $TEST_DIR +} + +_require_scratch_swapfile() +{ + _require_scratch + _scratch_mkfs >/dev/null + _scratch_mount + _require_swapfile $SCRATCH_MNT _scratch_unmount } diff --git a/tests/generic/472 b/tests/generic/472 index aba4a00719bc..d598eef37997 100755 --- a/tests/generic/472 +++ b/tests/generic/472 @@ -33,8 +33,6 @@ rm -f $seqres.full _supported_fs generic _supported_os Linux _require_scratch_swapfile -_require_test_program mkswap -_require_test_program swapon rm -f $seqres.full _scratch_mkfs >>$seqres.full 2>&1 diff --git a/tests/generic/495 b/tests/generic/495 index 88df26c78ec2..63f45cf4b336 100755 --- a/tests/generic/495 +++ b/tests/generic/495 @@ -31,8 +31,6 @@ rm -f $seqres.full _supported_fs generic _supported_os Linux _require_scratch_swapfile -_require_test_program mkswap -_require_test_program swapon _scratch_mkfs >> $seqres.full 2>&1 _scratch_mount diff --git a/tests/generic/496 b/tests/generic/496 index 3083eef0bebc..0e214909f596 100755 --- a/tests/generic/496 +++ b/tests/generic/496 @@ -34,8 +34,6 @@ rm -f $seqres.full _supported_fs generic _supported_os Linux _require_scratch_swapfile -_require_test_program mkswap -_require_test_program swapon _require_xfs_io_command "falloc" rm -f $seqres.full diff --git a/tests/generic/497 b/tests/generic/497 index 3d5502ef7c08..d9f9b7521eff 100755 --- a/tests/generic/497 +++ b/tests/generic/497 @@ -34,8 +34,6 @@ rm -f $seqres.full _supported_fs generic _supported_os Linux _require_scratch_swapfile -_require_test_program mkswap -_require_test_program swapon _require_xfs_io_command "fcollapse" rm -f $seqres.full