From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C071C77B7C for ; Thu, 20 Apr 2023 18:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jCDEW/smOmwBvOMJJJdt4SnrQCWrrDZuVuIkT4i7jsI=; b=mAJxpo29aHdND4oosDSGJIgPv5 bsdg3gR6meo22YUbe+L9IUUq/WjspaJf1gGWf1LOAs4HYdacIz/ytanBQPpkQZrmwT+zWfbLDaIMu IXPfEhuyOxP/PkKxkrf8/uy06sUj+zuDLh+hf7M3H9n1NDRXZ1V5fMtziZfhT+j/msxybj/DL4qrL 6TH78uzjsYlxrFc5Lxyn7SYCOfQTcWZKi+VCHPHHyv8Ixdb5tuWWBHLlL5hJ4bVZOA35CO7qN+uCF P+cahVTQk0Y9JZNITcxKcDaOq12OX0/HgF3NaPCgbqJgWEOXeNwEoHpXBl1v41r/FOQKyXjndD7vU vNj7Zaxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppZ48-008jpX-1N; Thu, 20 Apr 2023 18:31:32 +0000 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppZ43-008jl1-1K for linux-nvme@lists.infradead.org; Thu, 20 Apr 2023 18:31:29 +0000 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 214522195D; Thu, 20 Apr 2023 18:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682015485; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jCDEW/smOmwBvOMJJJdt4SnrQCWrrDZuVuIkT4i7jsI=; b=qtnqOBPzL9NWBt7v0dKcFXdQV9Vl+4YOJL5p9igF0RZj2k6aWxtXlAUvPV4yzJiov5MOco E03rj6PxlSn8LsWVbnz/aLrCAsnMcHlQH2CuKYOOVZ0z+PMRB/JyEzarLnXKGQvevg0Lxa AiEfWyYpJG79xEsdO+S3kcIXmef3toQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682015485; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jCDEW/smOmwBvOMJJJdt4SnrQCWrrDZuVuIkT4i7jsI=; b=t5hCA81h8mfhmwDGlN3KwrsphF0MZ5lS36wwe6nk6OAIUMghPLb1kOSosE6CyiJMKtr5T3 xvsAD1yuRKtIe9Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 12F2B13584; Thu, 20 Apr 2023 18:31:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eJadBP2EQWSfNAAAMHmgww (envelope-from ); Thu, 20 Apr 2023 18:31:25 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Chaitanya Kulkarni , Shin'ichiro Kawasaki , Daniel Wagner Subject: [PATCH blktests v2 1/9] nvme-rc: Auto convert test device size info Date: Thu, 20 Apr 2023 20:31:10 +0200 Message-Id: <20230420183121.4489-2-dwagner@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230420183121.4489-1-dwagner@suse.de> References: <20230420183121.4489-1-dwagner@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230420_113127_594033_4FDC8D23 X-CRM114-Status: GOOD ( 12.63 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org Introduce a convert_to_mb() helper which converts the size argument to MBytes and use in test device require function. This makes it possible to use user input strings in future. Signed-off-by: Daniel Wagner --- common/rc | 30 +++++++++++++++++++++++++++--- tests/nvme/035 | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/common/rc b/common/rc index af4c0b1cab22..dd0afda3d821 100644 --- a/common/rc +++ b/common/rc @@ -324,9 +324,12 @@ _get_pci_parent_from_blkdev() { tail -2 | head -1 } -_require_test_dev_size_mb() { - local require_sz_mb=$1 - local test_dev_sz_mb=$(($(blockdev --getsize64 "$TEST_DEV")/1024/1024)) +_require_test_dev_size() { + local require_sz_mb + local test_dev_sz_mb + + require_sz_mb="$(convert_to_mb "$1")" + test_dev_sz_mb="$(($(blockdev --getsize64 "$TEST_DEV")/1024/1024))" if (( "$test_dev_sz_mb" < "$require_sz_mb" )); then SKIP_REASONS+=("${TEST_DEV} required at least ${require_sz_mb}m") @@ -422,3 +425,24 @@ _have_writeable_kmsg() { _run_user() { su "$NORMAL_USER" -c "$1" } + +convert_to_mb() +{ + local str=$1 + local res + + res=$(echo "${str}" | sed -n 's/^\([0-9]\+\)$/\1/p') + if [[ -n "${res}" ]]; then + echo "$((res / 1024 / 1024))" + fi + + res=$(echo "${str}" | sed -n 's/^\([0-9]\+\)[mM]$/\1/p') + if [[ -n "${res}" ]]; then + echo "$((res))" + fi + + res=$(echo "${str}" | sed -n 's/^\([0-9]\+\)[gG]$/\1/p') + if [[ -n "${res}" ]]; then + echo "$((res * 1024))" + fi +} diff --git a/tests/nvme/035 b/tests/nvme/035 index d169e351e3d0..eb1024edddbf 100755 --- a/tests/nvme/035 +++ b/tests/nvme/035 @@ -17,7 +17,7 @@ requires() { } device_requires() { - _require_test_dev_size_mb 1024 + _require_test_dev_size 1024m } test_device() { -- 2.40.0