Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp468146rwr; Wed, 3 May 2023 01:04:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7FDsxpeNH64nOe/u8hb6JsyxkytaSMta+jiJcAzJbkeACYR/XW+is6ovXipXJ3PC5+P5jJ X-Received: by 2002:a17:902:e883:b0:1aa:d235:6dd4 with SMTP id w3-20020a170902e88300b001aad2356dd4mr1332489plg.19.1683101064940; Wed, 03 May 2023 01:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683101064; cv=none; d=google.com; s=arc-20160816; b=u4HSyagRUGiwZg3fNRRTQxcZXxsonsaycmTv10eyJufeCX+cZJZiek0FonGbKcSN9D /PZKtj5qdaaG37zdDW7ijzu29kMcrPJtomHHf+bjRCQMXYZp9ZuuokifPtENvHIiVNeI LerAaV18JpZSrc2n9hejwXcZgBocKMm9bt6G6+siCkFiO8v6Q7lMagwFOG1BV4QMrN7J TW2rVbcVOKOAx8PNfijC7EWVr30GT+sARjdkXxRt9b9zUOv35hixcvusk5ZN5lx/E6H6 QjzUSyKHtbgKyt0AnXH2e4TJviH1we4ah96RD/NoypIlGjE9IIMCQNwz7A8oxqmBU7FK e8HQ== 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=4bRFSw9rxVQLqGZBvGuslpAX0iVRdM7aaVOtxg8PZvc=; b=AAFcjI2C89rrJr8Y+6RdvA1W8arfsWX4ObgySRR+eClr1E+YExxBHqsWmtMlXHKVre Fi2mq9EsqraIZUz8p1trQ7E3dFxFzX3OQGstD7vVb2g2Gt5grVlwUYA+MjYM0GuFwPYG KsDyvvI5sbiJPtKJvVuBlINKuelqDSTVogj/LVbXnqd29v60YTfU08wN17qRqdmRFbSI zN/q5USoodJwm3izoJLnuksoX1m4yvo4+eMwYkJNmXbAQN8bTFPXP+KacNj/GFYooOjs 6xpKiuEWopA0PK3aog14zKzuCW1aU1iyHeYoNBeRgG80BxumHrVRYZEuqXm3yXCg8XKj 4c9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Ln27yFrq; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="0urN29/k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j23-20020a632317000000b0051a650b8f52si31694297pgj.259.2023.05.03.01.04.13; Wed, 03 May 2023 01:04:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Ln27yFrq; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="0urN29/k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229684AbjECIDO (ORCPT + 99 others); Wed, 3 May 2023 04:03:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbjECIDM (ORCPT ); Wed, 3 May 2023 04:03:12 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADAA7E74; Wed, 3 May 2023 01:03:11 -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 5393D200AB; Wed, 3 May 2023 08:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1683100990; 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=4bRFSw9rxVQLqGZBvGuslpAX0iVRdM7aaVOtxg8PZvc=; b=Ln27yFrqNCXB3yS7H42t6qvVNrubgyGezPoZuHu01peP63/liD61ZkJmTjRFp5/vZzwkHe 1aF5717Zn6huFHYHIVC3kQh3oielcTiAwvYqT+z9TUMkGsuOgtiuPXzlpJfepGFD5/daAi zCwhSEoFgPWubVx7X5hDPgwPjlwI/P0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1683100990; 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=4bRFSw9rxVQLqGZBvGuslpAX0iVRdM7aaVOtxg8PZvc=; b=0urN29/kP+PZyud7Sm9sj1ujYRc5hrDrTJMdcqntuI01TARrTwEcOWpLmh5tuuZqnmO4PO eavgtNg7qJdHfABQ== 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 463FE1331F; Wed, 3 May 2023 08:03:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ChkNET4VUmQtYgAAMHmgww (envelope-from ); Wed, 03 May 2023 08:03:10 +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 , Hannes Reinecke , Daniel Wagner Subject: [PATCH blktests v3 01/12] nvme/rc: Auto convert test device size info Date: Wed, 3 May 2023 10:02:47 +0200 Message-Id: <20230503080258.14525-2-dwagner@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230503080258.14525-1-dwagner@suse.de> References: <20230503080258.14525-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. Reviewed-by: Hannes Reinecke 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..0b15d1fe4c6b 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