diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2012-07-04 01:36:56 +0300 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2012-07-04 01:36:56 +0300 |
commit | 435f4edb6ed4a8e4920bb925c333ac0a610c14d2 (patch) | |
tree | ee2df7636d2ca8c8f25818dba8554e776a494d93 /tests/test_bindfs.rb | |
parent | 4799ba57707884a7d451434daa211eff2330678a (diff) | |
download | bindfs-435f4edb6ed4a8e4920bb925c333ac0a610c14d2.tar.gz |
Cache user data for user_belongs_to_group().
This considerably speeds up --mirror @group.
Diffstat (limited to 'tests/test_bindfs.rb')
-rwxr-xr-x | tests/test_bindfs.rb | 28 |
1 files changed, 28 insertions, 0 deletions
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 |