Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitef44d5b

Browse files
committed
Run tests on FreeBSD 10.3 and fix tests so they pass.
Fully fixes issuempartel#51.
1 parent3f10f21 commitef44d5b

File tree

5 files changed

+67
-23
lines changed

5 files changed

+67
-23
lines changed

‎tests/common.rb‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ def testenv(bindfs_args, options = {}, &block)
123123

124124
bindfs_pid=nil
125125
begin
126-
cmd="../#{EXECUTABLE_PATH}#{bindfs_args} -f#{Shellwords.escape(srcdir)}#{Shellwords.escape(mntdir)}"
126+
extra_args="-f"
127+
# Don't rely on user_allow_other in /etc/fuse.conf.
128+
# On FreeBSD it isn't even possible to set that.
129+
extra_args +=" --no-allow-other"ifProcess.uid !=0
130+
131+
cmd="../#{EXECUTABLE_PATH}#{bindfs_args}#{extra_args}#{Shellwords.escape(srcdir)}#{Shellwords.escape(mntdir)}"
127132
ifoptions[:valgrind]
128133
cmd="valgrind --error-exitcode=100#{options[:valgrind_opts]}#{cmd}"
129134
end

‎tests/readdir_inode.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ int main(int argc, char* argv[])
2020
return2;
2121
}
2222

23+
errno=0;
2324
dent=readdir(dirp);
2425
while (dent!=NULL) {
25-
if (errno!=0) {
26-
perror("failed to read directory entry");
27-
return3;
28-
}
2926
printf("%llu %s\n", (unsigned long long)dent->d_ino,dent->d_name);
3027
dent=readdir(dirp);
3128
}
29+
if (errno!=0) {
30+
perror("failed to read directory entry");
31+
return3;
32+
}
3233

3334
closedir(dirp);
3435

‎tests/test_bindfs.rb‎

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
$LOAD_PATH <<(ENV['srcdir'] ||'.')
2323

2424
require'common.rb'
25+
require'etc'
2526

2627
includeErrno
2728

@@ -49,6 +50,7 @@ def chown(user, group, list)
4950
$nobody_uid=nobody_uid=Etc.getpwnam('nobody').uid
5051
$nobody_gid=nobody_gid=Etc.getpwnam('nobody').gid
5152
$nobody_group=nobody_group=Etc.getgrgid(nobody_gid).name
53+
$root_group=root_group=Etc.getgrgid(0).name
5254

5355
$tests_dir=File.realpath('.')
5456

@@ -247,18 +249,20 @@ def run_chown_chgrp_test_case(chown_flag, chgrp_flag, expectations)
247249
assert{File.stat('mnt/file').gid == $nobody_gid}
248250
end
249251

250-
testenv("--chmod-allow-x --chmod-ignore")do
251-
touch('src/file')
252+
if`uname`.strip !='FreeBSD'# FreeBSD doesn't let us set the sticky bit on files
253+
testenv("--chmod-allow-x --chmod-ignore")do
254+
touch('src/file')
252255

253-
chmod(01700,'src/file')# sticky bit set
256+
chmod(01700,'src/file')# sticky bit set
254257

255-
chmod(00077,'mnt/file')# should change x bits; should not unset sticky bit
256-
assert{File.stat('src/file').mode &07777 ==01611}
258+
chmod(00077,'mnt/file')# should change x bits; should not unset sticky bit
259+
assert{File.stat('src/file').mode &07777 ==01611}
257260

258-
mkdir('src/dir')
259-
chmod(0700,'src/dir')
260-
chmod(0077,'mnt/dir')# bits on dir should not change
261-
assert{File.stat('src/dir').mode &0777 ==0700}
261+
mkdir('src/dir')
262+
chmod(0700,'src/dir')
263+
chmod(0077,'mnt/dir')# bits on dir should not change
264+
assert{File.stat('src/dir').mode &0777 ==0700}
265+
end
262266
end
263267

264268
testenv("--chmod-deny --chmod-allow-x")do
@@ -289,7 +293,7 @@ def run_chown_chgrp_test_case(chown_flag, chgrp_flag, expectations)
289293
assert{File.stat('src/file').mode &0777 ==0640}
290294
end
291295

292-
root_testenv("--map=nobody/root:@#{nobody_group}/@root")do
296+
root_testenv("--map=nobody/root:@#{nobody_group}/@#{root_group}")do
293297
touch('src/file')
294298
chown('nobody',nobody_group,'src/file')
295299

@@ -310,7 +314,7 @@ def run_chown_chgrp_test_case(chown_flag, chgrp_flag, expectations)
310314
assert{File.stat('mnt/newdir').gid ==0}
311315
end
312316

313-
root_testenv("--map=@#{nobody_group}/@root")do
317+
root_testenv("--map=@#{nobody_group}/@#{root_group}")do
314318
touch('src/file')
315319
chown('nobody',nobody_group,'src/file')
316320

@@ -377,20 +381,21 @@ def run_chown_chgrp_test_case(chown_flag, chgrp_flag, expectations)
377381
root_testenv("--uid-offset=2 --gid-offset=20",:title=>"file creation with --uid-offset and --gid-offset")do
378382
touch('mnt/file')
379383

380-
assert{File.stat('mnt/file').uid ==2}
381-
assert{File.stat('mnt/file').gid ==20}
382384
assert{File.stat('src/file').uid ==0}
383-
assert{File.stat('src/file').gid ==0}
385+
assert{File.stat('mnt/file').uid ==2}
386+
# Note: BSDs tend to inherit group from parent dir while Linux uses the effective GID.
387+
# This check works for both.
388+
assert{File.stat('mnt/file').gid ==File.stat('src/file').gid +20}
384389
end
385390

386391
root_testenv("--uid-offset=2 --gid-offset=20",:title=>"chown/chgrp with --uid-offset and --gid-offset")do
387392
touch('src/file')
388393
chown(6,25,'mnt/file')
389394

390-
assert{File.stat('mnt/file').uid ==6}
391-
assert{File.stat('mnt/file').gid ==25}
392395
assert{File.stat('src/file').uid ==4}
393396
assert{File.stat('src/file').gid ==5}
397+
assert{File.stat('mnt/file').uid ==6}
398+
assert{File.stat('mnt/file').gid ==25}
394399
end
395400

396401
testenv("",:title=>"preserves inode numbers")do
@@ -400,7 +405,7 @@ def run_chown_chgrp_test_case(chown_flag, chgrp_flag, expectations)
400405
assert{File.stat('mnt/dir').ino ==File.stat('src/dir').ino}
401406
end
402407

403-
testenv("",:title=>"has readdir inode numbers")do
408+
testenv("",:title=>"preserves readdir inode numbers")do
404409
touch('src/file')
405410
mkdir('src/dir')
406411

@@ -744,7 +749,8 @@ def run_chown_chgrp_test_case(chown_flag, chgrp_flag, expectations)
744749

745750
# FIXME: this stuff around testenv is a hax, and testenv may also exit(), which defeats the 'ensure' below.
746751
# the test setup ought to be refactored. It might well use MiniTest or something.
747-
ifProcess.uid ==0
752+
# TODO: support FreeBSD in this test (different group management commands)
753+
ifProcess.uid ==0 &&`uname`.strip =='Linux'
748754
begin
749755
`groupdel bindfs_test_group 2>&1`
750756
`groupadd -f bindfs_test_group`

‎vagrant/freebsd10_3/Vagrantfile‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure("2")do |config|
5+
#config.vm.box = "freebsd/FreeBSD-11.0-STABLE" # doesn't set base_mac so can't use NAT networking :(
6+
config.vm.box="bento/freebsd-10.3"
7+
8+
config.vm.synced_folder".","/vagrant",disabled:true
9+
config.vm.synced_folder"../../","/bindfs",
10+
type:"rsync",
11+
rsync__auto:false,
12+
rsync__exclude:["vagrant"],
13+
rsync__args:["-av","--delete-after"]
14+
15+
config.vm.provider"virtualbox"do |v|
16+
v.name="bindfs-freebsd10_3"
17+
end
18+
19+
config.vm.provision"shell",inline:<<-SHELL
20+
pkg update
21+
pkg install -y fusefs-libs pkgconf ruby valgrind
22+
23+
kldload fuse.ko
24+
echo 'fuse_load="YES"' >> /boot/loader.conf
25+
26+
sysctl vfs.usermount=1
27+
echo vfs.usermount=1 >> /etc/sysctl.conf
28+
29+
pw groupmod operator -m vagrant # For access to /dev/fuse
30+
SHELL
31+
end

‎vagrant/test.rb‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
end
4040

4141
puts"Running#{dirs.size} VMs in parallel:#{dirs.join(' ')}"
42+
puts"You can follow the progress of each VM by tailing vagrant/*/test.log"
4243
puts"Note: if your terminal goes wonky after this command, type 'reset'"
4344
mutex=Thread::Mutex.new# protects `$stdout` and `errors`
4445
errors=[]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp