So we are consistant while calculating the available disk space in
GB (one GB is 10**9 bytes, one GiB is 2**30 bytes). We do that by
adding the flag -H to the df call.

Signed-off-by: Jongki Suwandi <jsuwa...@google.com>
---
 client/common_lib/hosts/base_classes.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/client/common_lib/hosts/base_classes.py 
b/client/common_lib/hosts/base_classes.py
index 0b6ce0c..515f485 100644
--- a/client/common_lib/hosts/base_classes.py
+++ b/client/common_lib/hosts/base_classes.py
@@ -230,7 +230,9 @@ class Host(object):
     def check_diskspace(self, path, gb):
         logging.info('Checking for >= %s GB of space under %s on machine %s',
                      gb, path, self.hostname)
-        df = self.run('df -mP %s | tail -1' % path).stdout.split()
+        # 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
         if free_space_gb < gb:
             raise error.AutoservDiskFullHostError(path, gb, free_space_gb)
-- 
1.7.4

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to