Signed-off-by: Jongki Suwandi <[email protected]>
---
client/common_lib/base_packages.py | 6 ++++--
client/common_lib/hosts/base_classes.py | 7 +++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/client/common_lib/base_packages.py
b/client/common_lib/base_packages.py
index feb0d31..8a67004 100644
--- a/client/common_lib/base_packages.py
+++ b/client/common_lib/base_packages.py
@@ -50,13 +50,15 @@ def repo_run_command(repo, cmd, ignore_status=False):
def check_diskspace(repo, min_free=None):
+ # Note: 1 GB = 10**9 bytes (SI unit).
if not min_free:
min_free = global_config.global_config.get_config_value('PACKAGES',
'minimum_free_space',
type=int)
try:
- df = repo_run_command(repo, 'df -mP . | tail -1').stdout.split()
- free_space_gb = int(df[3])/1000.0
+ df = repo_run_command(repo,
+ 'df -PB %d . | tail -1' % 10**9).stdout.split()
+ free_space_gb = int(df[3])
except Exception, e:
raise error.RepoUnknownError('Unknown Repo Error: %s' % e)
if free_space_gb < min_free:
diff --git a/client/common_lib/hosts/base_classes.py
b/client/common_lib/hosts/base_classes.py
index 515f485..e0c240f 100644
--- a/client/common_lib/hosts/base_classes.py
+++ b/client/common_lib/hosts/base_classes.py
@@ -228,12 +228,11 @@ class Host(object):
def check_diskspace(self, path, gb):
+ # Note: 1 GB = 10**9 bytes (SI unit).
logging.info('Checking for >= %s GB of space under %s on machine %s',
gb, path, self.hostname)
- # Call df with -H, that provides output in powers of 1000, not 1024
- df = self.run('df -HmP %s | tail -1' % path).stdout.split()
- # Divide the resulting space by 1000, for a result in GB (10**9 bytes)
- free_space_gb = int(df[3])/1000.0
+ df = self.run('df -PB %d %s | tail -1' % (10**9, path)).stdout.split()
+ free_space_gb = int(df[3])
if free_space_gb < gb:
raise error.AutoservDiskFullHostError(path, gb, free_space_gb)
else:
--
1.7.3.1
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest