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: 10986181 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 245FF13AF for ; Tue, 11 Jun 2019 07:48:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16FFF271E6 for ; Tue, 11 Jun 2019 07:48:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B45C2845C; Tue, 11 Jun 2019 07:48:57 +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 9A8CF271E6 for ; Tue, 11 Jun 2019 07:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404485AbfFKHs4 (ORCPT ); Tue, 11 Jun 2019 03:48:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54424 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404064AbfFKHsz (ORCPT ); Tue, 11 Jun 2019 03:48:55 -0400 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 Cc: ltp@lists.linux.it, amir73il@gmail.com, chrubis@suse.cz, linux-fsdevel@vger.kernel.org, Murphy Zhou Subject: [PATCH v7 4/4] syscalls/swapoff/swapoff0{1,2}: use helpers to check support status 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) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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,