aboutsummaryrefslogtreecommitdiffstats
path: root/tests/common.rb
diff options
context:
space:
mode:
authorMartin Pärtel <martin.partel@gmail.com>2017-01-29 17:09:33 +0000
committerMartin Pärtel <martin.partel@gmail.com>2017-01-29 17:09:33 +0000
commit8f4b7de90989ab17260b6d7b926b2b71012475b3 (patch)
treede0b08e038cc2272c80d067502f248cdde0a3067 /tests/common.rb
parent18300876c860cad126fb316a82509a95c002d766 (diff)
downloadbindfs-8f4b7de90989ab17260b6d7b926b2b71012475b3.tar.gz
Fixed #47 by not setting `-ofsname=` when it would contain a comma.
Also banned some other characters that are likely to lead to trouble.
Diffstat (limited to 'tests/common.rb')
-rw-r--r--tests/common.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/common.rb b/tests/common.rb
index 518aab2..81d45fc 100644
--- a/tests/common.rb
+++ b/tests/common.rb
@@ -19,6 +19,7 @@
#
require 'fileutils'
+require 'shellwords'
include FileUtils
# Set the default umask for all tests
@@ -92,7 +93,9 @@ def testenv(bindfs_args, options = {}, &block)
options = {
:title => bindfs_args,
:valgrind => valgrind_options != nil,
- :valgrind_opts => valgrind_options
+ :valgrind_opts => valgrind_options,
+ :srcdir_name => 'src',
+ :mntdir_name => 'mnt'
}.merge(options)
# todo: less repetitive and more careful error handling and cleanup
@@ -100,6 +103,9 @@ def testenv(bindfs_args, options = {}, &block)
puts "--- #{options[:title]} ---"
puts "[ #{bindfs_args} ]"
+ srcdir = options[:srcdir_name]
+ mntdir = options[:mntdir_name]
+
begin
Dir.mkdir TESTDIR_NAME
rescue Exception => ex
@@ -108,15 +114,15 @@ def testenv(bindfs_args, options = {}, &block)
begin
Dir.chdir TESTDIR_NAME
- Dir.mkdir 'src'
- Dir.mkdir 'mnt'
+ Dir.mkdir srcdir
+ Dir.mkdir mntdir
rescue Exception => ex
fail!("ERROR preparing testdir at #{TESTDIR_NAME}", ex)
end
bindfs_pid = nil
begin
- cmd = "../#{EXECUTABLE_PATH} #{bindfs_args} -f src mnt"
+ cmd = "../#{EXECUTABLE_PATH} #{bindfs_args} -f #{Shellwords.escape(srcdir)} #{Shellwords.escape(mntdir)}"
if options[:valgrind]
cmd = "valgrind --error-exitcode=100 #{options[:valgrind_opts]} #{cmd}"
end
@@ -146,7 +152,7 @@ def testenv(bindfs_args, options = {}, &block)
end
begin
- unless system(umount_cmd + ' mnt')
+ unless system(umount_cmd + ' ' + Shellwords.escape(mntdir))
raise Exception.new(umount_cmd + " failed with status #{$?}")
end
Process.wait bindfs_pid