diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2016-07-31 19:39:11 +0100 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2016-07-31 19:39:11 +0100 |
commit | bc7e55aee064c06709dcc3cb329158cb6b75f935 (patch) | |
tree | 9b9d05f13f3e39714909014d666a6f8833176037 /tests/test_bindfs.rb | |
parent | e8a36fedff1e2836716a2345bd5c6b3565e990a1 (diff) | |
download | bindfs-bc7e55aee064c06709dcc3cb329158cb6b75f935.tar.gz |
Implemented --enable-lock-forwarding.
This should address #36.
Diffstat (limited to 'tests/test_bindfs.rb')
-rwxr-xr-x | tests/test_bindfs.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb index 04c853d..c0ae5dd 100755 --- a/tests/test_bindfs.rb +++ b/tests/test_bindfs.rb @@ -616,6 +616,47 @@ testenv("", :title => "many files in a directory") do assert { Dir.entries('mnt/dir').sort == expected_entries.sort } end +testenv("--enable-lock-forwarding --multithreaded", :title => "lock forwarding") do + File.write('src/file', 'some contents for fcntl lockng') + # (this test passes with an empty file as well, but this way is clearer) + + # flock + File.open('mnt/file') do |f1| + File.open('src/file') do |f2| + assert { f1.flock(File::LOCK_EX | File::LOCK_NB) } + assert { !f2.flock(File::LOCK_EX | File::LOCK_NB) } + assert { f1.flock(File::LOCK_UN) } + + assert { f2.flock(File::LOCK_EX | File::LOCK_NB) } + assert { !f1.flock(File::LOCK_EX | File::LOCK_NB) } + end + assert { f1.flock(File::LOCK_EX | File::LOCK_NB) } + end + + # fcntl locking + system("#{$tests_dir}/fcntl_locker src/file mnt/file") + raise "fcntl lock sharing test failed" unless $?.success? +end + +testenv("--disable-lock-forwarding", :title => "no lock forwarding") do + File.write('src/file', 'some contents for fcntl lockng') + + # flock + File.open('mnt/file') do |f1| + File.open('src/file') do |f2| + assert { f1.flock(File::LOCK_EX | File::LOCK_NB) } + assert { f2.flock(File::LOCK_EX | File::LOCK_NB) } + end + File.open('mnt/file') do |f2| + assert { !f2.flock(File::LOCK_EX | File::LOCK_NB) } + end + end + + # fcntl locking + system("#{$tests_dir}/fcntl_locker src/file mnt/file") + raise "fcntl lock sharing test failed" unless $?.exitstatus == 1 +end + # Issue #37 root_testenv("--enable-ioctl", :title => "append-only ioctl") do touch('mnt/file') |