aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/common.rb7
-rw-r--r--tests/readdir_inode.c9
-rwxr-xr-xtests/test_bindfs.rb42
-rw-r--r--vagrant/freebsd10_3/Vagrantfile31
-rwxr-xr-xvagrant/test.rb1
5 files changed, 67 insertions, 23 deletions
diff --git a/tests/common.rb b/tests/common.rb
index b3a14e4..24fd036 100644
--- a/tests/common.rb
+++ b/tests/common.rb
@@ -123,7 +123,12 @@ def testenv(bindfs_args, options = {}, &block)
bindfs_pid = nil
begin
- cmd = "../#{EXECUTABLE_PATH} #{bindfs_args} -f #{Shellwords.escape(srcdir)} #{Shellwords.escape(mntdir)}"
+ extra_args = "-f"
+ # Don't rely on user_allow_other in /etc/fuse.conf.
+ # On FreeBSD it isn't even possible to set that.
+ extra_args += " --no-allow-other" if Process.uid != 0
+
+ cmd = "../#{EXECUTABLE_PATH} #{bindfs_args} #{extra_args} #{Shellwords.escape(srcdir)} #{Shellwords.escape(mntdir)}"
if options[:valgrind]
cmd = "valgrind --error-exitcode=100 #{options[:valgrind_opts]} #{cmd}"
end
diff --git a/tests/readdir_inode.c b/tests/readdir_inode.c
index ed413be..532d2e2 100644
--- a/tests/readdir_inode.c
+++ b/tests/readdir_inode.c
@@ -20,15 +20,16 @@ int main(int argc, char* argv[])
return 2;
}
+ errno = 0;
dent = readdir(dirp);
while (dent != NULL) {
- if (errno != 0) {
- perror("failed to read directory entry");
- return 3;
- }
printf("%llu %s\n", (unsigned long long)dent->d_ino, dent->d_name);
dent = readdir(dirp);
}
+ if (errno != 0) {
+ perror("failed to read directory entry");
+ return 3;
+ }
closedir(dirp);
diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb
index 2badd30..ba30528 100755
--- a/tests/test_bindfs.rb
+++ b/tests/test_bindfs.rb
@@ -22,6 +22,7 @@
$LOAD_PATH << (ENV['srcdir'] || '.')
require 'common.rb'
+require 'etc'
include Errno
@@ -49,6 +50,7 @@ end
$nobody_uid = nobody_uid = Etc.getpwnam('nobody').uid
$nobody_gid = nobody_gid = Etc.getpwnam('nobody').gid
$nobody_group = nobody_group = Etc.getgrgid(nobody_gid).name
+$root_group = root_group = Etc.getgrgid(0).name
$tests_dir = File.realpath('.')
@@ -247,18 +249,20 @@ root_testenv("--mirror=root") do
assert { File.stat('mnt/file').gid == $nobody_gid }
end
-testenv("--chmod-allow-x --chmod-ignore") do
- touch('src/file')
+if `uname`.strip != 'FreeBSD' # FreeBSD doesn't let us set the sticky bit on files
+ testenv("--chmod-allow-x --chmod-ignore") do
+ touch('src/file')
- chmod(01700, 'src/file') # sticky bit set
+ chmod(01700, 'src/file') # sticky bit set
- chmod(00077, 'mnt/file') # should change x bits; should not unset sticky bit
- assert { File.stat('src/file').mode & 07777 == 01611 }
+ chmod(00077, 'mnt/file') # should change x bits; should not unset sticky bit
+ assert { File.stat('src/file').mode & 07777 == 01611 }
- mkdir('src/dir')
- chmod(0700, 'src/dir')
- chmod(0077, 'mnt/dir') # bits on dir should not change
- assert { File.stat('src/dir').mode & 0777 == 0700 }
+ mkdir('src/dir')
+ chmod(0700, 'src/dir')
+ chmod(0077, 'mnt/dir') # bits on dir should not change
+ assert { File.stat('src/dir').mode & 0777 == 0700 }
+ end
end
testenv("--chmod-deny --chmod-allow-x") do
@@ -289,7 +293,7 @@ testenv("--chmod-filter=g-w,o-rwx") do
assert { File.stat('src/file').mode & 0777 == 0640 }
end
-root_testenv("--map=nobody/root:@#{nobody_group}/@root") do
+root_testenv("--map=nobody/root:@#{nobody_group}/@#{root_group}") do
touch('src/file')
chown('nobody', nobody_group, 'src/file')
@@ -310,7 +314,7 @@ root_testenv("--map=nobody/root:@#{nobody_group}/@root") do
assert { File.stat('mnt/newdir').gid == 0 }
end
-root_testenv("--map=@#{nobody_group}/@root") do
+root_testenv("--map=@#{nobody_group}/@#{root_group}") do
touch('src/file')
chown('nobody', nobody_group, 'src/file')
@@ -377,20 +381,21 @@ end
root_testenv("--uid-offset=2 --gid-offset=20", :title => "file creation with --uid-offset and --gid-offset") do
touch('mnt/file')
- assert { File.stat('mnt/file').uid == 2 }
- assert { File.stat('mnt/file').gid == 20 }
assert { File.stat('src/file').uid == 0 }
- assert { File.stat('src/file').gid == 0 }
+ assert { File.stat('mnt/file').uid == 2 }
+ # Note: BSDs tend to inherit group from parent dir while Linux uses the effective GID.
+ # This check works for both.
+ assert { File.stat('mnt/file').gid == File.stat('src/file').gid + 20 }
end
root_testenv("--uid-offset=2 --gid-offset=20", :title => "chown/chgrp with --uid-offset and --gid-offset") do
touch('src/file')
chown(6, 25, 'mnt/file')
- assert { File.stat('mnt/file').uid == 6 }
- assert { File.stat('mnt/file').gid == 25 }
assert { File.stat('src/file').uid == 4 }
assert { File.stat('src/file').gid == 5 }
+ assert { File.stat('mnt/file').uid == 6 }
+ assert { File.stat('mnt/file').gid == 25 }
end
testenv("", :title => "preserves inode numbers") do
@@ -400,7 +405,7 @@ testenv("", :title => "preserves inode numbers") do
assert { File.stat('mnt/dir').ino == File.stat('src/dir').ino }
end
-testenv("", :title => "has readdir inode numbers") do
+testenv("", :title => "preserves readdir inode numbers") do
touch('src/file')
mkdir('src/dir')
@@ -744,7 +749,8 @@ 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
+# TODO: support FreeBSD in this test (different group management commands)
+if Process.uid == 0 && `uname`.strip == 'Linux'
begin
`groupdel bindfs_test_group 2>&1`
`groupadd -f bindfs_test_group`
diff --git a/vagrant/freebsd10_3/Vagrantfile b/vagrant/freebsd10_3/Vagrantfile
new file mode 100644
index 0000000..87ba424
--- /dev/null
+++ b/vagrant/freebsd10_3/Vagrantfile
@@ -0,0 +1,31 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure("2") do |config|
+ #config.vm.box = "freebsd/FreeBSD-11.0-STABLE" # doesn't set base_mac so can't use NAT networking :(
+ config.vm.box = "bento/freebsd-10.3"
+
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+ config.vm.synced_folder "../../", "/bindfs",
+ type: "rsync",
+ rsync__auto: false,
+ rsync__exclude: ["vagrant"],
+ rsync__args: ["-av", "--delete-after"]
+
+ config.vm.provider "virtualbox" do |v|
+ v.name = "bindfs-freebsd10_3"
+ end
+
+ config.vm.provision "shell", inline: <<-SHELL
+ pkg update
+ pkg install -y fusefs-libs pkgconf ruby valgrind
+
+ kldload fuse.ko
+ echo 'fuse_load="YES"' >> /boot/loader.conf
+
+ sysctl vfs.usermount=1
+ echo vfs.usermount=1 >> /etc/sysctl.conf
+
+ pw groupmod operator -m vagrant # For access to /dev/fuse
+ SHELL
+end
diff --git a/vagrant/test.rb b/vagrant/test.rb
index 3d14776..eff2a82 100755
--- a/vagrant/test.rb
+++ b/vagrant/test.rb
@@ -39,6 +39,7 @@ unless specifically_selected_vms.empty?
end
puts "Running #{dirs.size} VMs in parallel: #{dirs.join(' ')}"
+puts "You can follow the progress of each VM by tailing vagrant/*/test.log"
puts "Note: if your terminal goes wonky after this command, type 'reset'"
mutex = Thread::Mutex.new # protects `$stdout` and `errors`
errors = []