summaryrefslogtreecommitdiffstats
path: root/features/support/helpers/misc_helpers.rb
diff options
context:
space:
mode:
Diffstat (limited to 'features/support/helpers/misc_helpers.rb')
-rw-r--r--features/support/helpers/misc_helpers.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/features/support/helpers/misc_helpers.rb b/features/support/helpers/misc_helpers.rb
index 830fa1c..a0edf17 100644
--- a/features/support/helpers/misc_helpers.rb
+++ b/features/support/helpers/misc_helpers.rb
@@ -96,3 +96,18 @@ def get_tor_relays
cmd = 'awk "/^r/ { print \$6 }" /var/lib/tor/cached-microdesc-consensus'
@vm.execute(cmd).stdout.chomp.split("\n")
end
+
+def get_free_space(machine, path)
+ case machine
+ when 'host'
+ assert(File.exists?(path), "Path '#{path}' not found on #{machine}.")
+ free = cmd_helper("df '#{path}'")
+ when 'guest'
+ assert(@vm.file_exist?(path), "Path '#{path}' not found on #{machine}.")
+ free = @vm.execute_successfully("df '#{path}'")
+ else
+ raise 'Unsupported machine type #{machine} passed.'
+ end
+ output = free.split("\n").last
+ return output.match(/[^\s]\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+.*/)[1].chomp.to_i
+end