From patchwork Tue Jun 11 07:47:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murphy Zhou X-Patchwork-Id: 1113562 X-Patchwork-Delegate: wangli.ahau@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45NMZh1tPvz9sDB for ; Tue, 11 Jun 2019 17:49:00 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C71A43EAFF0 for ; Tue, 11 Jun 2019 09:48:57 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id C6B8B3EAEC1 for ; Tue, 11 Jun 2019 09:48:55 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 2B1F31A01142 for ; Tue, 11 Jun 2019 09:48:54 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5207C04B2F6; Tue, 11 Jun 2019 07:48:53 +0000 (UTC) Received: from localhost (dhcp-12-130.nay.redhat.com [10.66.12.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E16E60BCD; Tue, 11 Jun 2019 07:48:50 +0000 (UTC) From: Murphy Zhou To: liwang@redhat.com Date: Tue, 11 Jun 2019 15:47:40 +0800 Message-Id: <20190611074741.31903-3-xzhou@redhat.com> In-Reply-To: <20190611074741.31903-1-xzhou@redhat.com> References: <20190611074741.31903-1-xzhou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 11 Jun 2019 07:48:53 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Cc: linux-fsdevel@vger.kernel.org, ltp@lists.linux.it Subject: [LTP] [PATCH v7 3/4] syscalls/swapon/swapon0{1..3}: use helpers to check support status X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Of swap operations. Reviewed-by: Li Wang Signed-off-by: Murphy Zhou --- testcases/kernel/syscalls/swapon/swapon01.c | 11 ++--------- testcases/kernel/syscalls/swapon/swapon02.c | 13 +++---------- testcases/kernel/syscalls/swapon/swapon03.c | 15 ++++----------- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c index 32538f82b..f95ce0ab2 100644 --- a/testcases/kernel/syscalls/swapon/swapon01.c +++ b/testcases/kernel/syscalls/swapon/swapon01.c @@ -84,16 +84,9 @@ static void setup(void) tst_tmpdir(); - switch ((fs_type = tst_fs_type(cleanup, "."))) { - case TST_NFS_MAGIC: - case TST_TMPFS_MAGIC: - tst_brkm(TCONF, cleanup, - "Cannot do swapon on a file on %s filesystem", - tst_fs_type_name(fs_type)); - break; - } + is_swap_supported(cleanup, "./tstswap"); - make_swapfile(cleanup, "swapfile01"); + make_swapfile(cleanup, "swapfile01", 0); } static void cleanup(void) diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c index 4af5105c6..3d49d0c6b 100644 --- a/testcases/kernel/syscalls/swapon/swapon02.c +++ b/testcases/kernel/syscalls/swapon/swapon02.c @@ -132,18 +132,11 @@ static void setup(void) tst_tmpdir(); - switch ((fs_type = tst_fs_type(cleanup, "."))) { - case TST_NFS_MAGIC: - case TST_TMPFS_MAGIC: - tst_brkm(TCONF, cleanup, - "Cannot do swapon on a file on %s filesystem", - tst_fs_type_name(fs_type)); - break; - } + is_swap_supported(cleanup, "./tstswap"); SAFE_TOUCH(cleanup, "notswap", 0777, NULL); - make_swapfile(cleanup, "swapfile01"); - make_swapfile(cleanup, "alreadyused"); + make_swapfile(cleanup, "swapfile01", 0); + make_swapfile(cleanup, "alreadyused", 0); if (ltp_syscall(__NR_swapon, "alreadyused", 0)) { if (fs_type != TST_BTRFS_MAGIC || errno != EINVAL) diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c index 955ac247b..cef57150c 100644 --- a/testcases/kernel/syscalls/swapon/swapon03.c +++ b/testcases/kernel/syscalls/swapon/swapon03.c @@ -153,7 +153,7 @@ static int setup_swap(void) int j, fd; int status; int res = 0; - char filename[15]; + char filename[FILENAME_MAX]; char buf[BUFSIZ + 1]; /* Find out how many swapfiles (1 line per entry) already exist */ @@ -210,7 +210,7 @@ static int setup_swap(void) } /* Create the swapfile */ - make_swapfile(cleanup, filename); + make_swapfile(cleanup, filename, 0); /* turn on the swap file */ res = ltp_syscall(__NR_swapon, filename, 0); @@ -246,7 +246,7 @@ static int setup_swap(void) /* Create all needed extra swapfiles for testing */ for (j = 0; j < testfiles; j++) - make_swapfile(cleanup, swap_testfiles[j].filename); + make_swapfile(cleanup, swap_testfiles[j].filename, 0); return 0; @@ -333,14 +333,7 @@ static void setup(void) tst_tmpdir(); - switch ((fs_type = tst_fs_type(cleanup, "."))) { - case TST_NFS_MAGIC: - case TST_TMPFS_MAGIC: - tst_brkm(TCONF, cleanup, - "Cannot do swapon on a file on %s filesystem", - tst_fs_type_name(fs_type)); - break; - } + is_swap_supported(cleanup, "./tstswap"); TEST_PAUSE; }