diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-29 07:50:27 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-29 07:50:27 +0000 |
commit | e26c2bc21baac04ab52bff4eeedd9f41e4cb1f31 (patch) | |
tree | caf89974265b2d39ab74bf784009f0b52a4f8b4c /test/ruby | |
parent | b0c4ac77799fdf60a489f9e735158647c630865a (diff) | |
download | ruby-e26c2bc21baac04ab52bff4eeedd9f41e4cb1f31.tar.gz |
vm_trace.c: trace_func safe level check
* vm_trace.c (set_trace_func, thread_{add,set}_trace_func_m): check
safe level as well as 1.8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_settracefunc.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index af97651493..264b805127 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -397,6 +397,38 @@ class TestSetTraceFunc < Test::Unit::TestCase assert_equal(self, ok, bug3921) end + def assert_security_error_safe4 + func = lambda { + $SAFE = 4 + proc {yield} + }.call + assert_raise(SecurityError, &func) + end + + def test_set_safe4 + assert_security_error_safe4 do + set_trace_func(lambda {|*|}) + end + end + + def test_thread_set_safe4 + th = Thread.start {sleep} + assert_security_error_safe4 do + th.set_trace_func(lambda {|*|}) + end + ensure + th.kill + end + + def test_thread_add_safe4 + th = Thread.start {sleep} + assert_security_error_safe4 do + th.add_trace_func(lambda {|*|}) + end + ensure + th.kill + end + class << self define_method(:method_added, Module.method(:method_added)) end |