From patchwork Fri Jul 20 10:40:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 946817 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=none (p=none dis=none) header.from=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41X6MY0J5jz9s89 for ; Fri, 20 Jul 2018 20:20:08 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4F48E3E77D1 for ; Fri, 20 Jul 2018 12:20:06 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id 8A7783E78E3 for ; Fri, 20 Jul 2018 12:20:03 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-6.smtp.seeweb.it (Postfix) with ESMTP id 4A7FF1401DAA for ; Fri, 20 Jul 2018 12:20:01 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="42478490" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Jul 2018 18:19:57 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id E95084B625F5; Fri, 20 Jul 2018 18:19:54 +0800 (CST) Received: from RHEL7U5Alpha_SERVER.g08.fujitsu.local (10.167.220.156) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.399.0; Fri, 20 Jul 2018 18:19:54 +0800 From: Xiao Yang To: Date: Fri, 20 Jul 2018 18:40:12 +0800 Message-ID: <1532083213-4803-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20180719122126.GA16703@rei> References: <20180719122126.GA16703@rei> MIME-Version: 1.0 X-Originating-IP: [10.167.220.156] X-yoursite-MailScanner-ID: E95084B625F5.AB224 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No, score=0.0 required=7.0 tests=none autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Cc: ltp@lists.linux.it Subject: [LTP] [PATCH v3 1/2] lib: Factor out is_supported() && Add tst_supported_fs 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" 1) Factor out is_supported() and rename it as tst_fs_is_supported(), so that some tests can check a specified filesystem by it. 2) Add tst_supported_fs binary for shell tests to check a specified filesystem or all supported fielsystems. PS: hint messages from tst_supported_fs binary is targeted as stderr, so we can filter them by "2> /dev/null". Signed-off-by: Xiao Yang --- include/tst_fs.h | 6 +++++ lib/tst_supported_fs_types.c | 4 ++-- testcases/lib/Makefile | 2 +- testcases/lib/tst_supported_fs.c | 47 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 testcases/lib/tst_supported_fs.c diff --git a/include/tst_fs.h b/include/tst_fs.h index 73916a6..8d3f1cf 100644 --- a/include/tst_fs.h +++ b/include/tst_fs.h @@ -147,6 +147,12 @@ int tst_get_path(const char *prog_name, char *buf, size_t buf_len); int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); /* + * 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); + +/* * Returns NULL-terminated array of kernel-supported filesystems. */ const char **tst_get_supported_fs_types(void); diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c index a23b1ed..b7e647f 100644 --- a/lib/tst_supported_fs_types.c +++ b/lib/tst_supported_fs_types.c @@ -100,7 +100,7 @@ static int has_kernel_support(const char *fs_type) return 1; } -static int is_supported(const char *fs_type) +int tst_fs_is_supported(const char *fs_type) { return has_kernel_support(fs_type) && has_mkfs(fs_type); } @@ -110,7 +110,7 @@ const char **tst_get_supported_fs_types(void) unsigned int i, j = 0; for (i = 0; fs_type_whitelist[i]; i++) { - if (is_supported(fs_type_whitelist[i])) + if (tst_fs_is_supported(fs_type_whitelist[i])) fs_types[j++] = fs_type_whitelist[i]; } diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile index 398150a..14352d5 100644 --- a/testcases/lib/Makefile +++ b/testcases/lib/Makefile @@ -26,7 +26,7 @@ include $(top_srcdir)/include/mk/testcases.mk INSTALL_TARGETS := *.sh -MAKE_TARGETS := tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\ +MAKE_TARGETS := tst_supported_fs tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\ tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c new file mode 100644 index 0000000..ebebcbb --- /dev/null +++ b/testcases/lib/tst_supported_fs.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. + * Author: Xiao Yang + */ + +#include +#include + +#define TST_NO_DEFAULT_MAIN +#include "tst_test.h" +#include "tst_fs.h" + +static void usage(void) +{ + fprintf(stderr, "Usage: tst_supported_fs [fs_type]\n"); + fprintf(stderr, " If fs_type is supported, return 0\n"); + fprintf(stderr, " If fs_type isn't supported, return 1\n"); + fprintf(stderr, " If fs_type isn't specified, print the list of supported filesystems\n"); + fprintf(stderr, " fs_type - a specified filesystem type\n"); +} + +int main(int argc, char *argv[]) +{ + const char *const *filesystems; + int i; + + if (argc > 2) { + fprintf(stderr, "Can't specify multiple fs_type\n"); + usage(); + return 2; + } + + if (argv[1] && !strcmp(argv[1], "-h")) { + usage(); + return 0; + } + + if (argv[1]) + return !tst_fs_is_supported(argv[1]); + + filesystems = tst_get_supported_fs_types(); + for (i = 0; filesystems[i]; i++) + printf("%s\n", filesystems[i]); + + return 0; +} From patchwork Fri Jul 20 10:40:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 946818 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=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41X6Mh2LdHz9s7Q for ; Fri, 20 Jul 2018 20:20:15 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 44CE03E78F3 for ; Fri, 20 Jul 2018 12:20:10 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id AF88E3E773B for ; Fri, 20 Jul 2018 12:20:04 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-6.smtp.seeweb.it (Postfix) with ESMTP id DC0F41401DA6 for ; Fri, 20 Jul 2018 12:20:03 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="42478491" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Jul 2018 18:19:57 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 978024B62601; Fri, 20 Jul 2018 18:19:55 +0800 (CST) Received: from RHEL7U5Alpha_SERVER.g08.fujitsu.local (10.167.220.156) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.399.0; Fri, 20 Jul 2018 18:19:55 +0800 From: Xiao Yang To: Date: Fri, 20 Jul 2018 18:40:13 +0800 Message-ID: <1532083213-4803-2-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1532083213-4803-1-git-send-email-yangx.jy@cn.fujitsu.com> References: <20180719122126.GA16703@rei> <1532083213-4803-1-git-send-email-yangx.jy@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.156] X-yoursite-MailScanner-ID: 978024B62601.A585A X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No, score=0.0 required=7.0 tests=none autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Cc: ltp@lists.linux.it Subject: [LTP] [PATCH v3 2/2] zram/zram_lib.sh: Apply tst_supported_fs for shell 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" When mkfs command supports a specified filesystem and kernel doesn't support it, mkfs can format zram device to the filesystem successfully, but mount will fail with "unknown filesystem type". For example, running zram01 got the following error when only mkfs supported btrfs filesystem: --------------------------------------------------------------------------------- mount: /tmp/ltp-aJSv2PMZGl/zram01.46mBiYaa3M/zram3: unknown filesystem type 'btrfs'. --------------------------------------------------------------------------------- We should check both kernel and mkfs command by tst_supported_fs binary, and use ext2 fielsystem by default if either of them doesn't support a specified filesystem. Signed-off-by: Xiao Yang --- testcases/kernel/device-drivers/zram/zram_lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh index 224b407..36d1603 100755 --- a/testcases/kernel/device-drivers/zram/zram_lib.sh +++ b/testcases/kernel/device-drivers/zram/zram_lib.sh @@ -195,11 +195,11 @@ zram_swapoff() zram_makefs() { - tst_check_cmds mkfs which + tst_check_cmds mkfs local i=0 for fs in $zram_filesystems; do # if requested fs not supported default it to ext2 - which mkfs.$fs > /dev/null 2>&1 || fs=ext2 + tst_supported_fs $fs 2> /dev/null || fs=ext2 tst_resm TINFO "make $fs filesystem on /dev/zram$i" mkfs.$fs /dev/zram$i > err.log 2>&1