aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/common.rb10
-rwxr-xr-xtests/test_bindfs.rb28
2 files changed, 33 insertions, 5 deletions
diff --git a/tests/common.rb b/tests/common.rb
index 58d5d84..2563b38 100755
--- a/tests/common.rb
+++ b/tests/common.rb
@@ -126,12 +126,16 @@ def testenv(bindfs_args, options = {}, &block)
testcase_ok = true
begin
- yield
+ block.call(bindfs_pid)
rescue Exception => ex
fail("ERROR: testcase `#{options[:title]}' failed", ex)
testcase_ok = false
end
+ if File.exist?("bindfs.log")
+ system("cat bindfs.log")
+ end
+
begin
unless system(umount_cmd + ' mnt')
raise Exception.new(umount_cmd + " failed with status #{$?}")
@@ -141,10 +145,6 @@ def testenv(bindfs_args, options = {}, &block)
fail("ERROR: failed to umount")
testcase_ok = false
end
-
- if File.exist?("bindfs.log")
- system("cat bindfs.log")
- end
begin
Dir.chdir '..'
diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb
index 821b466..670be19 100755
--- a/tests/test_bindfs.rb
+++ b/tests/test_bindfs.rb
@@ -349,3 +349,31 @@ testenv("", :title => "has readdir inode numbers") do
assert { inodes['file'] == File.stat('src/file').ino }
assert { inodes['dir'] == File.stat('src/dir').ino }
end
+
+# FIXME: this stuff around testenv is a hax, and testenv may also exit(), which defeats the 'ensure' below.
+# the test setup ought to be refactored. It might well use MiniTest or something.
+if Process.uid == 0
+ begin
+ `groupdel bindfs_test_group 2>&1`
+ `groupadd -f bindfs_test_group`
+ raise "Failed to create test group" if !$?.success?
+ testenv("--mirror=@bindfs_test_group", :title => "SIGUSR1 rereads user database") do |bindfs_pid|
+ touch('src/file')
+ chown('nobody', nil, 'src/file')
+
+ assert { File.stat('mnt/file').uid == $nobody_uid }
+ `adduser root bindfs_test_group`
+ raise "Failed to add root to test group" if !$?.success?
+
+ # Cache not refreshed yet
+ assert { File.stat('mnt/file').uid == $nobody_uid }
+
+ Process.kill("SIGUSR1", bindfs_pid)
+ sleep 0.5
+
+ assert { File.stat('mnt/file').uid == 0 }
+ end
+ ensure
+ `groupdel bindfs_test_group 2>&1`
+ end
+end