|
19 | 19 | #
|
20 | 20 |
|
21 | 21 | # if we are being run by make check it will set srcdir and we should use it
|
22 |
| -localsrc_path=ENV['srcdir'] ||'.' |
| 22 | +$LOAD_PATH <<(ENV['srcdir'] ||'.') |
23 | 23 |
|
24 |
| -requirelocalsrc_path +'/common.rb' |
| 24 | +require'common.rb' |
25 | 25 |
|
26 | 26 | includeErrno
|
27 | 27 |
|
| 28 | +$have_fuse_29=Proc.newdo |
| 29 | +v=`pkg-config --modversion fuse`.split('.') |
| 30 | +raise"failed to get FUSE version with pkg-config"ifv.size <2 |
| 31 | +v=v.map(&:to_i) |
| 32 | +v=[2,8,0] |
| 33 | +v[0] >2 ||(v[0] ==2 &&v[1] >=9) |
| 34 | +end.call |
| 35 | + |
28 | 36 | # FileUtils.chown turned out to be quite buggy in Ruby 1.8.7,
|
29 | 37 | # so we'll use File.chown instead.
|
30 | 38 | defchown(user,group,list)
|
@@ -619,62 +627,70 @@ def run_chown_chgrp_test_case(chown_flag, chgrp_flag, expectations)
|
619 | 627 | assert{Dir.entries('mnt/dir').sort ==expected_entries.sort}
|
620 | 628 | end
|
621 | 629 |
|
622 |
| -testenv("--enable-lock-forwarding --multithreaded",:title=>"lock forwarding")do |
623 |
| -File.write('src/file','some contents for fcntl lockng') |
624 |
| -# (this test passes with an empty file as well, but this way is clearer) |
| 630 | +if $have_fuse_29 |
| 631 | +testenv("--enable-lock-forwarding --multithreaded",:title=>"lock forwarding")do |
| 632 | +File.write('src/file','some contents for fcntl lockng') |
| 633 | +# (this test passes with an empty file as well, but this way is clearer) |
625 | 634 |
|
626 |
| -# flock |
627 |
| -File.open('mnt/file')do |f1| |
628 |
| -File.open('src/file')do |f2| |
629 |
| -assert{f1.flock(File::LOCK_EX |File::LOCK_NB)} |
630 |
| -assert{ !f2.flock(File::LOCK_EX |File::LOCK_NB)} |
631 |
| -assert{f1.flock(File::LOCK_UN)} |
| 635 | +# flock |
| 636 | +File.open('mnt/file')do |f1| |
| 637 | +File.open('src/file')do |f2| |
| 638 | +assert{f1.flock(File::LOCK_EX |File::LOCK_NB)} |
| 639 | +assert{ !f2.flock(File::LOCK_EX |File::LOCK_NB)} |
| 640 | +assert{f1.flock(File::LOCK_UN)} |
632 | 641 |
|
633 |
| -assert{f2.flock(File::LOCK_EX |File::LOCK_NB)} |
634 |
| -assert{ !f1.flock(File::LOCK_EX |File::LOCK_NB)} |
| 642 | +assert{f2.flock(File::LOCK_EX |File::LOCK_NB)} |
| 643 | +assert{ !f1.flock(File::LOCK_EX |File::LOCK_NB)} |
| 644 | +end |
| 645 | +assert{f1.flock(File::LOCK_EX |File::LOCK_NB)} |
635 | 646 | end
|
636 |
| -assert{f1.flock(File::LOCK_EX |File::LOCK_NB)} |
637 |
| -end |
638 | 647 |
|
639 |
| -# fcntl locking |
640 |
| -system("#{$tests_dir}/fcntl_locker src/file mnt/file") |
641 |
| -raise"fcntl lock sharing test failed"unless $?.success? |
642 |
| -end |
| 648 | +# fcntl locking |
| 649 | +system("#{$tests_dir}/fcntl_locker src/file mnt/file") |
| 650 | +raise"fcntl lock sharing test failed"unless $?.success? |
| 651 | +end |
643 | 652 |
|
644 |
| -testenv("--disable-lock-forwarding",:title=>"no lock forwarding")do |
645 |
| -File.write('src/file','some contents for fcntl lockng') |
| 653 | +testenv("--disable-lock-forwarding",:title=>"no lock forwarding")do |
| 654 | +File.write('src/file','some contents for fcntl lockng') |
646 | 655 |
|
647 |
| -# flock |
648 |
| -File.open('mnt/file')do |f1| |
649 |
| -File.open('src/file')do |f2| |
650 |
| -assert{f1.flock(File::LOCK_EX |File::LOCK_NB)} |
651 |
| -assert{f2.flock(File::LOCK_EX |File::LOCK_NB)} |
652 |
| -end |
653 |
| -File.open('mnt/file')do |f2| |
654 |
| -assert{ !f2.flock(File::LOCK_EX |File::LOCK_NB)} |
| 656 | +# flock |
| 657 | +File.open('mnt/file')do |f1| |
| 658 | +File.open('src/file')do |f2| |
| 659 | +assert{f1.flock(File::LOCK_EX |File::LOCK_NB)} |
| 660 | +assert{f2.flock(File::LOCK_EX |File::LOCK_NB)} |
| 661 | +end |
| 662 | +File.open('mnt/file')do |f2| |
| 663 | +assert{ !f2.flock(File::LOCK_EX |File::LOCK_NB)} |
| 664 | +end |
655 | 665 | end
|
656 |
| -end |
657 | 666 |
|
658 |
| -# fcntl locking |
659 |
| -system("#{$tests_dir}/fcntl_locker src/file mnt/file") |
660 |
| -raise"fcntl lock sharing test failed"unless $?.exitstatus ==1 |
661 |
| -end |
| 667 | +# fcntl locking |
| 668 | +system("#{$tests_dir}/fcntl_locker src/file mnt/file") |
| 669 | +raise"fcntl lock sharing test failed"unless $?.exitstatus ==1 |
| 670 | +end |
| 671 | +end# have_fuse_29 |
662 | 672 |
|
663 | 673 | # Issue #37
|
664 |
| -# Valgrind disabled for ioctl tests since it seems to give a false negative |
| 674 | +# |
| 675 | +# Valgrind is disabled for ioctl tests since it seems to give a false negative |
665 | 676 | # about a null parameter to ioctl.
|
666 |
| -root_testenv("--enable-ioctl",:title=>"append-only ioctl",:valgrind=>false)do |
667 |
| -touch('mnt/file') |
668 |
| -system('chattr +a mnt/file') |
669 |
| -raise'chattr +a failed'unless $?.success? |
670 |
| -begin |
671 |
| -File.open('mnt/file','a')do |f| |
672 |
| -f.write('stuff') |
| 677 | +# |
| 678 | +# This test is also disabled for old (FUSE < 2.9) systems. |
| 679 | +# TODO: figure out why it doesn't work. |
| 680 | +if $have_fuse_29 |
| 681 | +root_testenv("--enable-ioctl",:title=>"append-only ioctl",:valgrind=>false)do |
| 682 | +touch('mnt/file') |
| 683 | +system('chattr +a mnt/file') |
| 684 | +raise'chattr +a failed'unless $?.success? |
| 685 | +begin |
| 686 | +File.open('mnt/file','a')do |f| |
| 687 | +f.write('stuff') |
| 688 | +end |
| 689 | +assert{File.read('mnt/file') =='stuff'} |
| 690 | +assert_exception(EPERM){File.write('mnt/file','newstuff')} |
| 691 | +ensure |
| 692 | +system('chattr -a mnt/file') |
673 | 693 | end
|
674 |
| -assert{File.read('mnt/file') =='stuff'} |
675 |
| -assert_exception(EPERM){File.write('mnt/file','newstuff')} |
676 |
| -ensure |
677 |
| -system('chattr -a mnt/file') |
678 | 694 | end
|
679 | 695 | end
|
680 | 696 |
|
|