diff options
author | Maciej Kisielewski <maciej.kisielewski@canonical.com> | 2021-04-13 22:26:18 +0200 |
---|---|---|
committer | Maciej Kisielewski <maciej.kisielewski@canonical.com> | 2021-04-14 00:01:10 +0200 |
commit | 78d3c267a839e6b97aba1c0f57a57afb2237e961 (patch) | |
tree | 5b4d3249501132db17a4f2780dbf325370f0b382 | |
parent | d6368d8712e8106902c7f9a9a8bf8cb0eecaf596 (diff) |
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.
-rwxr-xr-x | bin/storage_test.py | 11 |
1 files 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 |