Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1812167rwr; Thu, 20 Apr 2023 23:11:06 -0700 (PDT) X-Google-Smtp-Source: AKy350azBpxbg5yTRkbrpywFZbOCUwVpMYYMHOIvRwI7vVkKj2fORtc8TFfj8yfEhpr3B+B7ROen X-Received: by 2002:a05:6a20:1443:b0:f0:827f:4aff with SMTP id a3-20020a056a20144300b000f0827f4affmr5878328pzi.0.1682057466289; Thu, 20 Apr 2023 23:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682057466; cv=none; d=google.com; s=arc-20160816; b=GE9tF+dGbX/ndh1869VNDQIrN95aha3ebL4Xp873psAFfSV0+yuC5ppTWQ5DSp9O7v SFJ9mgw5m0pGeVX7iZS2QelFdqjM0idrWyrwrS1ejXCS64vytpiCsZseiquJDwbc1kV4 VedhhgZKty8bFvaEv9d8b3Fb7n6pDRv3aC1/6rEd6180IfyFwDU6YA4kEfj+TIH6vvQB 8Xljzqfqs2cne32TrIYqEfb/mmaEUCqElRfI52I5DnxulQuQ9qxx2fYfkf29iXdPdbyK 61zQsGJvN81EZDbVrjF73rHN7RDuQvn4KxpLoVTjZ6uTPuhageOs65v4x0fY8pHmUPTN XWHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=jCDEW/smOmwBvOMJJJdt4SnrQCWrrDZuVuIkT4i7jsI=; b=xVVw0MQ0nzI4+lVJOlwgntK3hDps/DYEHe63fUHd4edwelJTkqlsVu+vmS8sh6J3Hg 8GTyCy4959XT2nqzMzxUP7hYjXSNzKxfH+SuBla8OvrE59TMEjAPK8fVyhZTXSPbpD0A bf6is+gi2gAzwplLYelVjjmg3CyaLHQ0krUaf3VGH3J8EBtvdO66rkR6RrUs+sbqOLy7 tBBPpZdltuICxdTSDh69pd6LBkWvnud2dNZ1ZV6r7FVcGUQROYtpmIKktZVIe6BPuauq ZRLWKVGMdHzdpk7I3rRT2uuzbZReJIeTGVylVizB6eYam44MF2CfYOa2pwoTNvGoMLwy xSrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=RLm5wzmM; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x62-20020a638641000000b005205de8735fsi3890087pgd.36.2023.04.20.23.10.53; Thu, 20 Apr 2023 23:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=RLm5wzmM; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233700AbjDUGGD (ORCPT + 99 others); Fri, 21 Apr 2023 02:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233764AbjDUGFv (ORCPT ); Fri, 21 Apr 2023 02:05:51 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D22876EB6; Thu, 20 Apr 2023 23:05:47 -0700 (PDT) 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-out2.suse.de (Postfix) with ESMTPS id 655AB1FDDB; Fri, 21 Apr 2023 06:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682057116; 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=RLm5wzmMTMIk5hQhJgWZ5aafAt1lCgSmxu0OQ4GjIuytkJNNz2/7dJu28AACIL1bYK7Ccd pyjHLV2H7K6RNydqkWfjFRqvGvKD1XDoxK87rxzKtrWTqb7SWnNL5Crewkvmn2sS17U/O2 KCfzhl1byXivbkcYSgAuDEJ4wGfzKHE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682057116; 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=31+NDckKwxc41+DKq0w44zYD/iV3XFvBiFIBlqh0nGlgRQAvdLYFVf3bNnUAQ8ROLcM4B9 NAKevrwTpl/MrADg== 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 580B21390E; Fri, 21 Apr 2023 06:05:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ME1nFZwnQmRqZgAAMHmgww (envelope-from ); Fri, 21 Apr 2023 06:05:16 +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 REPOST blktests v2 1/9] nvme-rc: Auto convert test device size info Date: Fri, 21 Apr 2023 08:04:57 +0200 Message-Id: <20230421060505.10132-2-dwagner@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230421060505.10132-1-dwagner@suse.de> References: <20230421060505.10132-1-dwagner@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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