From 78d3c267a839e6b97aba1c0f57a57afb2237e961 Mon Sep 17 00:00:00 2001 From: Maciej Kisielewski Date: Tue, 13 Apr 2021 22:26:18 +0200 Subject: Fix: make storage_test run only on known FSes Previously the storage_test looked for the largest partition on a given drive and tried running bonnie++ on it. If the largest partition was an unformatted space or an unknown FS bonnie would fail. This patch changes the test so it looks for partitions of known FS types. --- bin/storage_test.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/storage_test.py b/bin/storage_test.py index 9efe41f..22110b2 100755 --- a/bin/storage_test.py +++ b/bin/storage_test.py @@ -25,15 +25,18 @@ def mountpoint(device): def find_largest_partition(device): - BlkDev = namedtuple('BlkDev', ['name', 'size', 'type']) - cmd = 'lsblk -b -l -n -o NAME,SIZE,TYPE {}'.format(device) + BlkDev = namedtuple( + 'BlkDev', ['name', 'size', 'type', 'fstype'], + defaults=[None, None, None, None]) + cmd = 'lsblk -b -l -n -o NAME,SIZE,TYPE,FSTYPE {}'.format(device) out = sp.check_output(cmd, shell=True) blk_devs = [BlkDev(*p.strip().split()) for p in out.decode(sys.stdout.encoding).splitlines()] - blk_devs[:] = [bd for bd in blk_devs if bd.type in ('part', 'md')] + blk_devs[:] = [bd for bd in blk_devs if ( + bd.type in ('part', 'md') and bd.fstype is not None)] if not blk_devs: raise SystemExit( - 'ERROR: No partitions found on device {}'.format(device)) + 'ERROR: No suitable partitions found on device {}'.format(device)) blk_devs.sort(key=lambda bd: int(bd.size)) return blk_devs[-1].name -- cgit v1.2.3