8000 * test/ruby/test_io.rb (test_fcntl_lock_freebsd): add a testcase · ileitch/ruby@f2708ce · GitHub
[go: up one dir, main page]

Skip to content

Commit f2708ce

Browse files
author
kosaki
committed
* test/ruby/test_io.rb (test_fcntl_lock_freebsd): add a testcase
of fcntl lock for freebsd. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 791f544 commit f2708ce

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Sat Nov 12 11:18:17 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
2+
3+
* test/ruby/test_io.rb (test_fcntl_lock_freebsd): add a testcase
4+
of fcntl lock for freebsd.
5+
16
Sat Nov 12 11:16:32 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
27

38
* io.c (ioctl_narg_len): Linux doesn't have IOCPARM_LEN macro, but

test/ruby/test_io.rb

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ def test_invalid_advise
18501850
end
18511851
end
18521852

1853-
def test_fcntl_lock
1853+
def test_fcntl_lock_linux
18541854
return if /x86_64-linux/ !~ RUBY_PLATFORM # A binary form of struct flock depend on platform
18551855

18561856
pad=0
@@ -1883,6 +1883,41 @@ def test_fcntl_lock
18831883
end
18841884
end
18851885

1886+
def test_fcntl_lock_freebsd
1887+
return if /freebsd/ !~ RUBY_PLATFORM # A binary form of struct flock depend on platform
1888+
1889+
start = 12
1890+
len = 34
1891+
sysid = 0
1892+
Tempfile.open(self.class.name) do |f|
1893+
r, w = IO.pipe
1894+
pid = fork do
1895+
r.close
1896+
lock = [start, len, 0, Fcntl::F_WRLCK, IO::SEEK_SET, sysid].pack("qqis!s!i!")
1897+
f.fcntl Fcntl::F_SETLKW, lock
1898+
w.syswrite "."
1899+
sleep
1900+
end
1901+
w.close
1902+
assert_equal ".", r.read(1)
1903+
r.close
1904+
1905+
getlock = [0, 0, 0, Fcntl::F_WRLCK, 0, 0].pack("qqis!s!i!")
1906+
f.fcntl Fcntl::F_GETLK, getlock
1907+
1908+
start, len, lockpid, ptype, whence, sysid = getlock.unpack("qqis!s!i!")
1909+
1910+
assert_equal(ptype, Fcntl::F_WRLCK)
1911+
assert_equal(whence, IO::SEEK_SET)
1912+
assert_equal(start, 12)
1913+
assert_equal(len, 34)
1914+
assert_equal(pid, lockpid)
1915+
1916+
Process.kill :TERM, pid
1917+
Process.waitpid2(pid)
1918+
end
1919+
end
1920+
18861921
def test_cross_thread_close_fd
18871922
skip "cross thread close causes hung-up if pipe." if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
18881923
with_pipe do |r,w|

0 commit comments

Comments
 (0)
0