summaryrefslogtreecommitdiffstats
path: root/test/dl
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-25 00:11:15 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-25 00:11:15 +0000
commita6954947faf3ba505ed8169c9b7cdd7e27cd13ab (patch)
tree292697f25ece9d734bd890f607bb5d36e628e7dd /test/dl
parentfef55edeecbe78b34f89347016b41ea9f06aad1a (diff)
downloadruby-a6954947faf3ba505ed8169c9b7cdd7e27cd13ab.tar.gz
ruby-a6954947faf3ba505ed8169c9b7cdd7e27cd13ab.tar.xz
ruby-a6954947faf3ba505ed8169c9b7cdd7e27cd13ab.zip
* ext/dl/handle.c (rb_dlhandle_sym) refactoring rb_secure(2)
* test/dl/test_handle.rb (**) testing sym behavior git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/dl')
-rw-r--r--test/dl/test_handle.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/dl/test_handle.rb b/test/dl/test_handle.rb
index 59582e96b..ab9c1c13a 100644
--- a/test/dl/test_handle.rb
+++ b/test/dl/test_handle.rb
@@ -2,6 +2,25 @@ require 'test_base'
module DL
class TestHandle < TestBase
+ def test_static_sym_secure
+ assert_raises(SecurityError) do
+ Thread.new do
+ $SAFE = 2
+ DL::Handle.sym('calloc')
+ end.join
+ end
+ end
+
+ def test_static_sym_unknown
+ assert_raises(DL::DLError) { DL::Handle.sym('fooo') }
+ assert_raises(DL::DLError) { DL::Handle['fooo'] }
+ end
+
+ def test_static_sym
+ assert DL::Handle.sym('dlopen')
+ assert_equal DL::Handle.sym('dlopen'), DL::Handle['dlopen']
+ end
+
def test_sym_closed_handle
handle = DL::Handle.new(LIBC_SO)
handle.close
@@ -21,6 +40,16 @@ module DL
assert_raises(TypeError) { handle[nil] }
end
+ def test_sym_secure
+ assert_raises(SecurityError) do
+ Thread.new do
+ $SAFE = 2
+ handle = DL::Handle.new(LIBC_SO)
+ handle.sym('calloc')
+ end.join
+ end
+ end
+
def test_sym
handle = DL::Handle.new(LIBC_SO)
assert handle.sym('calloc')