Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1216015rwr; Thu, 20 Apr 2023 11:32:19 -0700 (PDT) X-Google-Smtp-Source: AKy350b6qfKftHZMphIUkGRgYjm1Ny71LgXKjk//0G2GJaOGDGgDLMsRsHYOXNbisaK92ZRs8YwB X-Received: by 2002:a05:6a20:ab88:b0:f0:302a:ccdf with SMTP id da8-20020a056a20ab8800b000f0302accdfmr2516812pzb.52.1682015539346; Thu, 20 Apr 2023 11:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682015539; cv=none; d=google.com; s=arc-20160816; b=iw8KznblpqcDDFeSs2cbFWK50esdxHWkVW/lgGXR3X73zj0vS4xkGUs4Vix2gB5LdX hQ7u4alS/qbp/0rJ92DOSr4xlkhk1dySCY/4apt+0hm65jwlePLDBrETp3DzZqQYi/I1 z7PN1BNJHVJElVdadRJLYEGXGV36lOLjnlxoEfJ/DIQYDcpx2v5vIFcuAW8ozLi4TY+g kSjBgG5j4C7yaa+Vf6nEVNmZ2OItPQndtWWMxKeailJ3QtUUi4+8K6OdLhYSV03NR9Cf DAgBP3o/miQIB0Cw6f0GN+Cpt2ujTojfS3vVoRbuod4wh7jGwSfE8QtZ/2NSeMIhC62n ja2A== 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=MV+jwe6qwdixQ6RtrykHl5dza8/3spqL0Jw2UcDLWUFPUWA5KeOz+dEvyj9hzdm3ln NKwOX8mry/b1X+NRomwp27LsxhpuqIKzfHDWnKw83qSs7raE/PVp+/Vcdo2JMBGPm/49 Lwew8qHjqLsTgKbSeNHQMA7A0iGeUB/Lzbb+3yzevC/7QCYFfjCBf+GoaP6AqkafPYoG 0wFY3yFxizXUQaT50N3ugZUrqh4Js9/c7653WQUlkSN5uYD18e234rPy2P6xCOf0emwl SpuxqLVACBQuhYCqdxaqq1yngAjRr+XDjc82S6pQXdoOk/bBJbQ8+WMC3z9n30oLpiYT ZoVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qtnqOBPz; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=t5hCA81h; 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 bv66-20020a632e45000000b0050faafb6a11si2006913pgb.807.2023.04.20.11.32.05; Thu, 20 Apr 2023 11:32:19 -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=qtnqOBPz; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=t5hCA81h; 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 S231298AbjDTSba (ORCPT + 99 others); Thu, 20 Apr 2023 14:31:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjDTSb1 (ORCPT ); Thu, 20 Apr 2023 14:31:27 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 705A830E3; Thu, 20 Apr 2023 11:31:26 -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-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-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 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