From patchwork Wed Jun 19 12:31:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1118673 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=none (p=none dis=none) header.from=suse.cz 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 45TPTY2CHNz9sP8 for ; Wed, 19 Jun 2019 22:32:00 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id DA5643EA90A for ; Wed, 19 Jun 2019 14:31:57 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 6DB743EA2E9 for ; Wed, 19 Jun 2019 14:31:51 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id C1DED600B28 for ; Wed, 19 Jun 2019 14:31:50 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5E018AD3B; Wed, 19 Jun 2019 12:31:50 +0000 (UTC) From: Cyril Hrubis To: ltp@lists.linux.it Date: Wed, 19 Jun 2019 14:31:47 +0200 Message-Id: <20190619123148.29733-2-chrubis@suse.cz> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190619123148.29733-1-chrubis@suse.cz> References: <20190619123148.29733-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 1/2] lib: Add flags to tst_get_supported_fs_types() 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" Now we can ask the library to filter-out FUSE backed fs types. Signed-off-by: Cyril Hrubis CC: Amir Goldstein CC: Sumit Garg --- include/tst_fs.h | 6 ++++-- include/tst_test.h | 2 ++ lib/tst_supported_fs_types.c | 15 ++++++++++----- lib/tst_test.c | 2 +- testcases/lib/tst_supported_fs.c | 4 ++-- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/tst_fs.h b/include/tst_fs.h index ebca065c6..62071e508 100644 --- a/include/tst_fs.h +++ b/include/tst_fs.h @@ -162,16 +162,18 @@ int tst_fill_fd(int fd, char pattern, size_t bs, size_t bcount); */ int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); +#define TST_FS_SKIP_FUSE 0x01 + /* * Return 1 if a specified fiilsystem is supported * Return 0 if a specified fiilsystem isn't supported */ -int tst_fs_is_supported(const char *fs_type); +int tst_fs_is_supported(const char *fs_type, int flags); /* * Returns NULL-terminated array of kernel-supported filesystems. */ -const char **tst_get_supported_fs_types(void); +const char **tst_get_supported_fs_types(int flags); /* * Creates and writes to files on given path until write fails with ENOSPC diff --git a/include/tst_test.h b/include/tst_test.h index 8bdf38482..2e8e36352 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -154,6 +154,8 @@ struct tst_test { /* Device filesystem type override NULL == default */ const char *dev_fs_type; + /* Flags to be passed to tst_get_supported_fs_types() */ + int dev_fs_flags; /* Options passed to SAFE_MKFS() when format_device is set */ const char *const *dev_fs_opts; diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c index 9babcc31a..00ede549d 100644 --- a/lib/tst_supported_fs_types.c +++ b/lib/tst_supported_fs_types.c @@ -45,7 +45,7 @@ static int has_mkfs(const char *fs_type) return 1; } -static int has_kernel_support(const char *fs_type) +static int has_kernel_support(const char *fs_type, int flags) { static int fuse_supported = -1; const char *tmpdir = getenv("TMPDIR"); @@ -84,21 +84,26 @@ static int has_kernel_support(const char *fs_type) return 0; } + if (flags & TST_FS_SKIP_FUSE) { + tst_res(TINFO, "Skipping FUSE as requested by the test"); + return 0; + } + tst_res(TINFO, "FUSE does support %s", fs_type); return 1; } -int tst_fs_is_supported(const char *fs_type) +int tst_fs_is_supported(const char *fs_type, int flags) { - return has_kernel_support(fs_type) && has_mkfs(fs_type); + return has_kernel_support(fs_type, flags) && has_mkfs(fs_type); } -const char **tst_get_supported_fs_types(void) +const char **tst_get_supported_fs_types(int flags) { unsigned int i, j = 0; for (i = 0; fs_type_whitelist[i]; i++) { - if (tst_fs_is_supported(fs_type_whitelist[i])) + if (tst_fs_is_supported(fs_type_whitelist[i], flags)) fs_types[j++] = fs_type_whitelist[i]; } diff --git a/lib/tst_test.c b/lib/tst_test.c index c08da6a80..245e287fa 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -1151,7 +1151,7 @@ static int run_tcases_per_fs(void) { int ret = 0; unsigned int i; - const char *const *filesystems = tst_get_supported_fs_types(); + const char *const *filesystems = tst_get_supported_fs_types(tst_test->dev_fs_flags); if (!filesystems[0]) tst_brk(TCONF, "There are no supported filesystems"); diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c index ebebcbb37..022a61508 100644 --- a/testcases/lib/tst_supported_fs.c +++ b/testcases/lib/tst_supported_fs.c @@ -37,9 +37,9 @@ int main(int argc, char *argv[]) } if (argv[1]) - return !tst_fs_is_supported(argv[1]); + return !tst_fs_is_supported(argv[1], 0); - filesystems = tst_get_supported_fs_types(); + filesystems = tst_get_supported_fs_types(0); for (i = 0; filesystems[i]; i++) printf("%s\n", filesystems[i]);