From patchwork Wed Jul 11 08:55:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 942368 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 41QXsR13NHzB4MP for ; Wed, 11 Jul 2018 18:53:12 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 14A0F3E6C4D for ; Wed, 11 Jul 2018 10:53:09 +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 DE0973E6971 for ; Wed, 11 Jul 2018 10:53:07 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-3.smtp.seeweb.it (Postfix) with ESMTP id C6DAC1A00F83 for ; Wed, 11 Jul 2018 10:53:06 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="42111399" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Jul 2018 16:53:04 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 504894B445CB; Wed, 11 Jul 2018 16:53:00 +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; Wed, 11 Jul 2018 16:52:57 +0800 From: Xiao Yang To: Date: Wed, 11 Jul 2018 16:55:25 +0800 Message-ID: <1531299325-27779-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.167.220.156] X-yoursite-MailScanner-ID: 504894B445CB.A9836 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-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH] zram/zram_lib.sh: Check fielsystem support more throughly 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 add a fielsystem support check for both kernel and mkfs command, 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 | 18 ++++++++++++++++-- 1 file changed, 16 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..d6ce74a 100755 --- a/testcases/kernel/device-drivers/zram/zram_lib.sh +++ b/testcases/kernel/device-drivers/zram/zram_lib.sh @@ -193,13 +193,27 @@ zram_swapoff() tst_resm TPASS "swapoff completed" } +zram_check_fs_support() +{ + tst_check_cmds which modprobe + local filesystem=$1 + + # Check if mkfs command supports fs + which mkfs.$filesystem > /dev/null 2>&1 || return 1 + + # Check if kernel supports fs + if ! grep -qw $filesystem /proc/filesystems; then + modprobe $filesystem > /dev/null 2>&1 || return 1 + fi +} + 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 + zram_check_fs_support $fs || fs=ext2 tst_resm TINFO "make $fs filesystem on /dev/zram$i" mkfs.$fs /dev/zram$i > err.log 2>&1