public inbox for nvdimm@lists.linux.dev
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Schofield, Alison" <alison.schofield@intel.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Cc: "Weiny, Ira" <ira.weiny@intel.com>
Subject: Re: [ndctl PATCH] test/rescan-partitions.sh: refine search for created partition
Date: Wed, 4 Sep 2024 00:25:12 +0000	[thread overview]
Message-ID: <f3ffd3d136bb7bea61368f1ee16a5ce37ba7ba27.camel@intel.com> (raw)
In-Reply-To: <20240828192620.302092-1-alison.schofield@intel.com>

On Wed, 2024-08-28 at 12:26 -0700, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
> 
> Unit test rescan-partitions.sh can fail because the grep test looking
> for the expected partition is overly broad and can match multiple
> pmem devices.
> 
> /root/ndctl/build/meson-logs/testlog.txt reports this failure:
> test/rescan-partitions.sh: failed at line 50
> 
> An example of an improper grep is:
> 'pmem10 pmem12 pmem1p1' when only 'pmem1p1' was expected
> 
> Replace the faulty grep with a query of the lsblk JSON output that
> examines the children of this blockdev only and matches on size.
> 
> This type of pesky issue is probably arising as the unit tests are
> being run in more complex environments and may also be due to other
> unit tests not properly cleaning up after themselves. No matter the
> cause this change makes this test more robust and that's a good
> thing!
> 
> Reported-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
>  test/rescan-partitions.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/test/rescan-partitions.sh b/test/rescan-partitions.sh
> index 51bbd731fb55..ccb542cb2f68 100755
> --- a/test/rescan-partitions.sh
> +++ b/test/rescan-partitions.sh
> @@ -24,6 +24,7 @@ check_min_kver "4.16" || do_skip "may not contain
> fixes for partition rescanning
>  
>  check_prereq "parted"
>  check_prereq "blockdev"
> +check_prereq "jq"
>  
>  test_mode()
>  {
> @@ -46,7 +47,10 @@ test_mode()
>  	sleep 1
>  	blockdev --rereadpt /dev/$blockdev
>  	sleep 1
> -	partdev="$(grep -Eo "${blockdev}.+" /proc/partitions)"
> +	partdev=$(lsblk -J -o NAME,SIZE /dev/$blockdev |
> +		jq -r '.blockdevices[] | .children[] |
> +		select(.size == "9M") | .name')

Hm slight reaction to the size == 9M check that wasn't there before.

Would it be better to just use .children[0].name instead of looking for
a specific 9M sized partition? May be more robust if the size ever
changes for some reason.

Otherwise looks good,

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>


      reply	other threads:[~2024-09-04  0:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28 19:26 [ndctl PATCH] test/rescan-partitions.sh: refine search for created partition alison.schofield
2024-09-04  0:25 ` Verma, Vishal L [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3ffd3d136bb7bea61368f1ee16a5ce37ba7ba27.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=nvdimm@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox