From patchwork Tue Jun 11 07:47:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murphy Zhou X-Patchwork-Id: 1113560 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 45NMZG4ZpNz9sCJ for ; Tue, 11 Jun 2019 17:48:38 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8E0BD3EAFF5 for ; Tue, 11 Jun 2019 09:48:34 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id C9B923EAEBE for ; Tue, 11 Jun 2019 09:48:31 +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-5.smtp.seeweb.it (Postfix) with ESMTPS id 9A98A6009B3 for ; Tue, 11 Jun 2019 09:48:33 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C37F30860B7; Tue, 11 Jun 2019 07:48:29 +0000 (UTC) Received: from localhost (dhcp-12-130.nay.redhat.com [10.66.12.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8CA85C22E; Tue, 11 Jun 2019 07:48:26 +0000 (UTC) From: Murphy Zhou To: liwang@redhat.com Date: Tue, 11 Jun 2019 15:47:38 +0800 Message-Id: <20190611074741.31903-1-xzhou@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 11 Jun 2019 07:48:29 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-5.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-5.smtp.seeweb.it Cc: linux-fsdevel@vger.kernel.org, ltp@lists.linux.it Subject: [LTP] [PATCH v7 1/4] lib/tst_ioctl.c: add helper tst_fibmap 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" To check if FIBMAP ioctl is supported by the filesystem we are testing on. It also can check the support status of specific files, but that may not needed for now. Reviewed-by: Li Wang Signed-off-by: Murphy Zhou --- v7: Make tst_fibmap return value more accurate Print errno if fibmap ioctl does not succeed Make swapoff02 use new helper Mute some build warnnings cc linux-fsdevel list Overall diff stat: include/tst_fs.h | 5 +++++ lib/tst_ioctl.c | 37 +++++++++++++++++++++++++++++++++++++ testcases/kernel/syscalls/swapoff/Makefile | 3 ++- testcases/kernel/syscalls/swapoff/Makefile.inc | 6 ++++++ testcases/kernel/syscalls/swapoff/swapoff01.c | 10 ++-------- testcases/kernel/syscalls/swapoff/swapoff02.c | 11 ++--------- testcases/kernel/syscalls/swapon/libswapon.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- testcases/kernel/syscalls/swapon/libswapon.h | 7 ++++++- testcases/kernel/syscalls/swapon/swapon01.c | 11 ++--------- testcases/kernel/syscalls/swapon/swapon02.c | 13 +++---------- testcases/kernel/syscalls/swapon/swapon03.c | 15 ++++----------- 11 files changed, 112 insertions(+), 51 deletions(-) v6: Modify make_swapfile() to check mkswap support status safely Remove whitelist Remove BTRFS EINVAL check Check mkswap status before testing swapon in helper If swapon pass, following swapoff failure will fail the whole test and break Also modify swapoff02 to remove whitelist completely v5: Split to 4 patches Only take one filename parameter in tst_fibmap Add helper is_swap_supported to check swap operation support status Test fibmap/swapon and swapoff operation in the helper Keep NFS/TMPFS whitelist Keep BTRFS EINVAL handling logic, except above 2 situation: if swapon fails and fibmap is not supported, tst_brk with TCONF if swapon fails and fibmap is supported, tst_brk with TFAIL If swapon test pass in the helper, test swapoff similarly Put is_swap_supported helper in libswapon, link swapoff binaries to it Mute a sprintf filaname wanrning by the way v4: Fail softly if FIBMAP nit supported, instead of skip entire testcase v3: Fix fs_type undeclared in swapoff01.c v2: Test FIBMAP instead of fstype whitelist include/tst_fs.h | 5 +++++ lib/tst_ioctl.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 lib/tst_ioctl.c diff --git a/include/tst_fs.h b/include/tst_fs.h index ebca065c6..6d03371ec 100644 --- a/include/tst_fs.h +++ b/include/tst_fs.h @@ -178,6 +178,11 @@ const char **tst_get_supported_fs_types(void); */ void tst_fill_fs(const char *path, int verbose); +/* + * test if FIBMAP ioctl is supported + */ +int tst_fibmap(const char *filename); + #ifdef TST_TEST_H__ static inline long tst_fs_type(const char *path) { diff --git a/lib/tst_ioctl.c b/lib/tst_ioctl.c new file mode 100644 index 000000000..364220bcd --- /dev/null +++ b/lib/tst_ioctl.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include + +#define TST_NO_DEFAULT_MAIN + +#include "tst_test.h" + +int tst_fibmap(const char *filename) +{ + /* test if FIBMAP ioctl is supported */ + int fd, block = 0; + + fd = open(filename, O_RDWR | O_CREAT, 0666); + if (fd < 0) { + tst_res(TWARN | TERRNO, + "open(%s, O_RDWR | O_CREAT, 0666) failed", filename); + return -1; + } + + if (ioctl(fd, FIBMAP, &block)) { + tst_res(TINFO | TERRNO, "FIBMAP ioctl is NOT supported"); + close(fd); + return 1; + } + tst_res(TINFO, "FIBMAP ioctl is supported"); + + if (close(fd)) { + tst_res(TWARN | TERRNO, "close(fd) failed"); + return -1; + } + return 0; +} From patchwork Tue Jun 11 07:47:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murphy Zhou X-Patchwork-Id: 1113561 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=2001:1418:10:5::2; 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 [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45NMZZ131xz9sDB for ; Tue, 11 Jun 2019 17:48:54 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6F8B23EAFF7 for ; Tue, 11 Jun 2019 09:48:51 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id 389013EAEBE for ; Tue, 11 Jun 2019 09:48:50 +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-5.smtp.seeweb.it (Postfix) with ESMTPS id 20544600A91 for ; Tue, 11 Jun 2019 09:48:51 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E47B882F5; Tue, 11 Jun 2019 07:48:48 +0000 (UTC) Received: from localhost (dhcp-12-130.nay.redhat.com [10.66.12.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 059701972C; Tue, 11 Jun 2019 07:48:41 +0000 (UTC) From: Murphy Zhou To: liwang@redhat.com Date: Tue, 11 Jun 2019 15:47:39 +0800 Message-Id: <20190611074741.31903-2-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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 11 Jun 2019 07:48:48 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-5.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-5.smtp.seeweb.it Cc: linux-fsdevel@vger.kernel.org, ltp@lists.linux.it Subject: [LTP] [PATCH v7 2/4] swapon/libswapon: add helper is_swap_supported 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" To check if the filesystem we are testing on supports FIBMAP, mkswap, swapon and swapoff operations. Survivor of this function should support swapfile function well, like swapon and swapoff. Modify make_swapfile function to test mkswap support status safely. Reviewed-by: Li Wang Signed-off-by: Murphy Zhou --- testcases/kernel/syscalls/swapon/libswapon.c | 45 +++++++++++++++++++- testcases/kernel/syscalls/swapon/libswapon.h | 7 ++- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/syscalls/swapon/libswapon.c b/testcases/kernel/syscalls/swapon/libswapon.c index cf6a98891..0a4501bdd 100644 --- a/testcases/kernel/syscalls/swapon/libswapon.c +++ b/testcases/kernel/syscalls/swapon/libswapon.c @@ -19,13 +19,15 @@ * */ +#include +#include "lapi/syscalls.h" #include "test.h" #include "libswapon.h" /* * Make a swap file */ -void make_swapfile(void (cleanup)(void), const char *swapfile) +int make_swapfile(void (cleanup)(void), const char *swapfile, int safe) { if (!tst_fs_has_free(NULL, ".", sysconf(_SC_PAGESIZE) * 10, TST_BYTES)) { @@ -45,5 +47,44 @@ void make_swapfile(void (cleanup)(void), const char *swapfile) argv[1] = swapfile; argv[2] = NULL; - tst_run_cmd(cleanup, argv, "/dev/null", "/dev/null", 0); + return tst_run_cmd(cleanup, argv, "/dev/null", "/dev/null", safe); +} + +/* + * Check swapon/swapoff support status of filesystems or files + * we are testing on. + */ +void is_swap_supported(void (cleanup)(void), const char *filename) +{ + int fibmap = tst_fibmap(filename); + long fs_type = tst_fs_type(cleanup, filename); + const char *fstype = tst_fs_type_name(fs_type); + + int ret = make_swapfile(NULL, filename, 1); + if (ret != 0) { + if (fibmap == 1) { + tst_brkm(TCONF, cleanup, + "mkswap on %s not supported", fstype); + } else { + tst_brkm(TFAIL, cleanup, + "mkswap on %s failed", fstype); + } + } + + TEST(ltp_syscall(__NR_swapon, filename, 0)); + if (TEST_RETURN == -1) { + if (fibmap == 1 && errno == EINVAL) { + tst_brkm(TCONF, cleanup, + "Swapfile on %s not implemented", fstype); + } else { + tst_brkm(TFAIL | TERRNO, cleanup, + "swapon on %s failed", fstype); + } + } + + TEST(ltp_syscall(__NR_swapoff, filename, 0)); + if (TEST_RETURN == -1) { + tst_brkm(TFAIL | TERRNO, cleanup, + "swapoff on %s failed", fstype); + } } diff --git a/testcases/kernel/syscalls/swapon/libswapon.h b/testcases/kernel/syscalls/swapon/libswapon.h index 7f7211eb4..a51833ec1 100644 --- a/testcases/kernel/syscalls/swapon/libswapon.h +++ b/testcases/kernel/syscalls/swapon/libswapon.h @@ -29,6 +29,11 @@ /* * Make a swap file */ -void make_swapfile(void (cleanup)(void), const char *swapfile); +int make_swapfile(void (cleanup)(void), const char *swapfile, int safe); +/* + * Check swapon/swapoff support status of filesystems or files + * we are testing on. + */ +void is_swap_supported(void (cleanup)(void), const char *filename); #endif /* __LIBSWAPON_H__ */ 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; } From patchwork Tue Jun 11 07:47:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murphy Zhou X-Patchwork-Id: 1113563 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 45NMZn1hPCz9sDB for ; Tue, 11 Jun 2019 17:49:05 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B4C733EB072 for ; Tue, 11 Jun 2019 09:49:02 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id BB4E23EB006 for ; Tue, 11 Jun 2019 09:48:57 +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-5.smtp.seeweb.it (Postfix) with ESMTPS id 72DA0600B05 for ; Tue, 11 Jun 2019 09:48:59 +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 A9B803082E25; Tue, 11 Jun 2019 07:48:55 +0000 (UTC) Received: from localhost (dhcp-12-130.nay.redhat.com [10.66.12.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2626360BC9; Tue, 11 Jun 2019 07:48:54 +0000 (UTC) From: Murphy Zhou To: liwang@redhat.com Date: Tue, 11 Jun 2019 15:47:41 +0800 Message-Id: <20190611074741.31903-4-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.46]); Tue, 11 Jun 2019 07:48:55 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-5.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-5.smtp.seeweb.it Cc: linux-fsdevel@vger.kernel.org, ltp@lists.linux.it Subject: [LTP] [PATCH v7 4/4] syscalls/swapoff/swapoff0{1, 2}: 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. Change Makefile to use functions from ../swapon/libswapon.c Reviewed-by: Li Wang Signed-off-by: Murphy Zhou --- testcases/kernel/syscalls/swapoff/Makefile | 3 ++- testcases/kernel/syscalls/swapoff/Makefile.inc | 6 ++++++ testcases/kernel/syscalls/swapoff/swapoff01.c | 10 ++-------- testcases/kernel/syscalls/swapoff/swapoff02.c | 11 ++--------- 4 files changed, 12 insertions(+), 18 deletions(-) create mode 100644 testcases/kernel/syscalls/swapoff/Makefile.inc diff --git a/testcases/kernel/syscalls/swapoff/Makefile b/testcases/kernel/syscalls/swapoff/Makefile index bd617d806..536b2dbac 100644 --- a/testcases/kernel/syscalls/swapoff/Makefile +++ b/testcases/kernel/syscalls/swapoff/Makefile @@ -19,5 +19,6 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk - +include $(abs_srcdir)/./Makefile.inc include $(top_srcdir)/include/mk/generic_leaf_target.mk +$(MAKE_TARGETS): %: %.o ../swapon/libswapon.o diff --git a/testcases/kernel/syscalls/swapoff/Makefile.inc b/testcases/kernel/syscalls/swapoff/Makefile.inc new file mode 100644 index 000000000..65350cbeb --- /dev/null +++ b/testcases/kernel/syscalls/swapoff/Makefile.inc @@ -0,0 +1,6 @@ +LIBDIR += ../swapon/ +LIBSWAPON := $(LIBDIR)/libswapon.o +$(LIBSWAPON): + $(MAKE) -C $(LIBDIR) +CPPFLAGS += -I$(abs_srcdir)/$(LIBDIR) +LDFLAGS += -L$(abs_builddir)/$(LIBDIR) diff --git a/testcases/kernel/syscalls/swapoff/swapoff01.c b/testcases/kernel/syscalls/swapoff/swapoff01.c index a63e661a5..e115269c0 100644 --- a/testcases/kernel/syscalls/swapoff/swapoff01.c +++ b/testcases/kernel/syscalls/swapoff/swapoff01.c @@ -25,6 +25,7 @@ #include #include "config.h" #include "lapi/syscalls.h" +#include "../swapon/libswapon.h" static void setup(void); static void cleanup(void); @@ -86,14 +87,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 swapoff on a file on %s filesystem", - tst_fs_type_name(fs_type)); - break; - } + is_swap_supported(cleanup, "./tstswap"); if (!tst_fs_has_free(NULL, ".", 64, TST_MB)) { tst_brkm(TBROK, cleanup, diff --git a/testcases/kernel/syscalls/swapoff/swapoff02.c b/testcases/kernel/syscalls/swapoff/swapoff02.c index b5c6312a1..8954f975f 100644 --- a/testcases/kernel/syscalls/swapoff/swapoff02.c +++ b/testcases/kernel/syscalls/swapoff/swapoff02.c @@ -33,6 +33,7 @@ #include "test.h" #include "lapi/syscalls.h" #include "safe_macros.h" +#include "../swapon/libswapon.h" static void setup(void); static void cleanup(void); @@ -124,7 +125,6 @@ static void cleanup01(void) static void setup(void) { - long type; struct passwd *nobody; tst_sig(FORK, DEF_HANDLER, cleanup); @@ -138,14 +138,7 @@ static void setup(void) tst_tmpdir(); - switch ((type = tst_fs_type(cleanup, "."))) { - case TST_NFS_MAGIC: - case TST_TMPFS_MAGIC: - tst_brkm(TCONF, cleanup, - "Cannot do swapoff on a file on %s filesystem", - tst_fs_type_name(type)); - break; - } + is_swap_supported(cleanup, "./tstswap"); if (!tst_fs_has_free(NULL, ".", 1, TST_KB)) { tst_brkm(TBROK, cleanup,