diff --git a/tests/test_partitions.py b/tests/test_partitions.py index eb980dee18ed464a42e45280e30b8d28f3e56654..a82cff1e5b9088b22265ebdf4b0a77cfa1c5393b 100755 --- a/tests/test_partitions.py +++ b/tests/test_partitions.py @@ -24,6 +24,7 @@ def read_file(fname): with open(fname, 'r') as f: return f.read() + paths = [ { 'mount_point': '/', @@ -67,8 +68,8 @@ def get_swap_gbytes(): def get_path(path): - # Filesystem Type 1B-blocks Used Available Use% Mounted on - # /dev/loop2 ext4 52710469632 38253940736 11755397120 77% / + # Filesystem Type 1B-blocks Used Available + # /dev/loop2 ext4 52710469632 38253940736 11755397120 status, output = subprocess.getstatusoutput('df --output="source,fstype,size,avail" -B 1 %s | tail -n 1' % path) if status == 0: dev, fstype, size, available = output.split() @@ -79,6 +80,8 @@ def get_path(path): def check_allocation(dev): root_dev = os.path.basename(dev)[:3] + if not root_dev: + return True d = read_file('/proc/partitions') dev_partitions = list() for l in d.split('\n'): @@ -101,6 +104,7 @@ def check_allocation(dev): return False return True + error = False warning = False @@ -119,7 +123,7 @@ def check_path(p): if fstype not in p.get('recommended_types'): print('Warning, partition of %s fs type not recommended %s(current: %s, recommended: %s)%s.' % (name, YELLOW, fstype, p['recommended_types'], DEF)) warning = True - if 'nfs' not in dev: + if 'nfs' not in fstype: warning = not check_allocation(dev) min_available_gbytes = p.get('min_available_gbytes') if min_available_gbytes and available < min_available_gbytes: @@ -141,6 +145,7 @@ def check_path(p): print('Partition of %s is smaller than the recommended size %s(%s GB < %s GB)%s.' % (name, YELLOW, psize, p['reco_size_gbytes'], DEF)) warning = True + for p in paths: check_path(p)