Skip to content

Commit

Permalink
test/rescan-partitions.sh: refine search for created partition
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Vishal Verma <[email protected]>
Link: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Alison Schofield <[email protected]>
  • Loading branch information
AlisonSchofield committed Oct 2, 2024
1 parent dfa937e commit ed9c3c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/rescan-partitions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -46,7 +47,9 @@ 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[0] | .name')

test -b /dev/$partdev

# cycle the namespace, and verify the partition is read
Expand Down

0 comments on commit ed9c3c0

Please sign in to comment.