aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-12 02:31:15 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-12 02:31:15 +0000
commitf2708ce30f0bf7c7a0ace010a7f8461de1e41f8b (patch)
tree3d6ccd6f7701dcc442dc61cbf80ab54b502fa0ff
parent791f5449c170467ebe7f43d06047ec3d61d141eb (diff)
downloadruby-f2708ce30f0bf7c7a0ace010a7f8461de1e41f8b.tar.gz
* 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
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_io.rb37
2 files changed, 41 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 857783b06e..8b849f6e2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Nov 12 11:18:17 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * test/ruby/test_io.rb (test_fcntl_lock_freebsd): add a testcase
+ of fcntl lock for freebsd.
+
Sat Nov 12 11:16:32 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* io.c (ioctl_narg_len): Linux doesn't have IOCPARM_LEN macro, but
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index f7670a1293..21a215d67a 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1850,7 +1850,7 @@ End
end
end
- def test_fcntl_lock
+ def test_fcntl_lock_linux
return if /x86_64-linux/ !~ RUBY_PLATFORM # A binary form of struct flock depend on platform
pad=0
@@ -1883,6 +1883,41 @@ End
end
end
+ def test_fcntl_lock_freebsd
+ return if /freebsd/ !~ RUBY_PLATFORM # A binary form of struct flock depend on platform
+
+ start = 12
+ len = 34
+ sysid = 0
+ Tempfile.open(self.class.name) do |f|
+ r, w = IO.pipe
+ pid = fork do
+ r.close
+ lock = [start, len, 0, Fcntl::F_WRLCK, IO::SEEK_SET, sysid].pack("qqis!s!i!")
+ f.fcntl Fcntl::F_SETLKW, lock
+ w.syswrite "."
+ sleep
+ end
+ w.close
+ assert_equal ".", r.read(1)
+ r.close
+
+ getlock = [0, 0, 0, Fcntl::F_WRLCK, 0, 0].pack("qqis!s!i!")
+ f.fcntl Fcntl::F_GETLK, getlock
+
+ start, len, lockpid, ptype, whence, sysid = getlock.unpack("qqis!s!i!")
+
+ assert_equal(ptype, Fcntl::F_WRLCK)
+ assert_equal(whence, IO::SEEK_SET)
+ assert_equal(start, 12)
+ assert_equal(len, 34)
+ assert_equal(pid, lockpid)
+
+ Process.kill :TERM, pid
+ Process.waitpid2(pid)
+ end
+ end
+
def test_cross_thread_close_fd
skip "cross thread close causes hung-up if pipe." if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
with_pipe do |r,w|