From 2b914b59147c7fd19fe7847d073ea640a053c0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu> Date: Wed, 1 Aug 2018 13:43:39 +0200 Subject: [PATCH] Fixed a bug in partitions test (refs #26179). --- tests/test_partitions.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_partitions.py b/tests/test_partitions.py index eb980dee..a82cff1e 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) -- GitLab