diff options
Diffstat (limited to 'trunk/test/drb')
-rw-r--r-- | trunk/test/drb/drbtest.rb | 352 | ||||
-rw-r--r-- | trunk/test/drb/ignore_test_drb.rb | 24 | ||||
-rw-r--r-- | trunk/test/drb/test_acl.rb | 195 | ||||
-rw-r--r-- | trunk/test/drb/test_drb.rb | 301 | ||||
-rw-r--r-- | trunk/test/drb/test_drbssl.rb | 62 | ||||
-rw-r--r-- | trunk/test/drb/test_drbunix.rb | 46 | ||||
-rw-r--r-- | trunk/test/drb/ut_array.rb | 15 | ||||
-rw-r--r-- | trunk/test/drb/ut_array_drbssl.rb | 24 | ||||
-rw-r--r-- | trunk/test/drb/ut_array_drbunix.rb | 15 | ||||
-rw-r--r-- | trunk/test/drb/ut_drb.rb | 160 | ||||
-rw-r--r-- | trunk/test/drb/ut_drb_drbssl.rb | 25 | ||||
-rw-r--r-- | trunk/test/drb/ut_drb_drbunix.rb | 16 | ||||
-rw-r--r-- | trunk/test/drb/ut_eval.rb | 31 | ||||
-rw-r--r-- | trunk/test/drb/ut_large.rb | 38 | ||||
-rw-r--r-- | trunk/test/drb/ut_port.rb | 14 | ||||
-rw-r--r-- | trunk/test/drb/ut_safe1.rb | 15 | ||||
-rw-r--r-- | trunk/test/drb/ut_timerholder.rb | 49 |
17 files changed, 0 insertions, 1382 deletions
diff --git a/trunk/test/drb/drbtest.rb b/trunk/test/drb/drbtest.rb deleted file mode 100644 index 143d856a1e..0000000000 --- a/trunk/test/drb/drbtest.rb +++ /dev/null @@ -1,352 +0,0 @@ -require 'test/unit' -require 'drb/drb' -require 'drb/extservm' -require 'timeout' -begin - loadpath = $:.dup - $:.replace($: | [File.expand_path("../ruby", File.dirname(__FILE__))]) - require 'envutil' -ensure - $:.replace(loadpath) -end - -class DRbService - @@manager = DRb::ExtServManager.new - @@ruby = EnvUtil.rubybin - @@ruby += " -d" if $DEBUG - def self.add_service_command(nm) - dir = File.dirname(File.expand_path(__FILE__)) - DRb::ExtServManager.command[nm] = "\"#{@@ruby}\" \"#{dir}/#{nm}\"" - end - - %w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb).each do |nm| - add_service_command(nm) - end - @server = @@server = DRb::DRbServer.new('druby://localhost:0', @@manager, {}) - @@manager.uri = @@server.uri - def self.manager - @@manager - end - def self.server - @server || @@server - end - def self.ext_service(name) - timeout(100, RuntimeError) do - manager.service(name) - end - end -end - -class Onecky - include DRbUndumped - def initialize(n) - @num = n - end - - def to_i - @num.to_i - end - - def sleep(n) - Kernel.sleep(n) - to_i - end -end - -class FailOnecky < Onecky - class OneckyError < RuntimeError; end - def to_i - raise(OneckyError, @num.to_s) - end -end - -class XArray < Array - def initialize(ary) - ary.each do |x| - self.push(x) - end - end -end - -module DRbCore - def setup - @ext = DRbService.ext_service('ut_drb.rb') - @there = @ext.front - end - - def teardown - @ext.stop_service if @ext - end - - def test_00_DRbObject - ro = DRbObject.new(nil, 'druby://localhost:12345') - assert_equal('druby://localhost:12345', ro.__drburi) - assert_equal(nil, ro.__drbref) - - ro = DRbObject.new_with_uri('druby://localhost:12345') - assert_equal('druby://localhost:12345', ro.__drburi) - assert_equal(nil, ro.__drbref) - - ro = DRbObject.new_with_uri('druby://localhost:12345?foobar') - assert_equal('druby://localhost:12345', ro.__drburi) - assert_equal(DRb::DRbURIOption.new('foobar'), ro.__drbref) - end - - def test_01 - assert_equal("hello", @there.hello) - onecky = Onecky.new('3') - assert_equal(6, @there.sample(onecky, 1, 2)) - ary = @there.to_a - assert_kind_of(DRb::DRbObject, ary) - - assert(@there.respond_to?(:to_a, true)) - assert(@there.respond_to?(:eval, true)) - assert(! @there.respond_to?(:eval, false)) - assert(! @there.respond_to?(:eval)) - end - - def test_01_02_loop - onecky = Onecky.new('3') - 50.times do - assert_equal(6, @there.sample(onecky, 1, 2)) - ary = @there.to_a - assert_kind_of(DRb::DRbObject, ary) - end - end - - def test_02_unknown - obj = @there.unknown_class - assert_kind_of(DRb::DRbUnknown, obj) - assert_equal('Unknown2', obj.name) - - obj = @there.unknown_module - assert_kind_of(DRb::DRbUnknown, obj) - if RUBY_VERSION >= '1.8' - assert_equal('DRbEx::', obj.name) - else - assert_equal('DRbEx', obj.name) - end - - assert_raises(DRb::DRbUnknownError) do - @there.unknown_error - end - - onecky = FailOnecky.new('3') - - assert_raises(FailOnecky::OneckyError) do - @there.sample(onecky, 1, 2) - end - end - - def test_03 - assert_equal(8, @there.sum(1, 1, 1, 1, 1, 1, 1, 1)) - assert_raises(ArgumentError) do - @there.sum(1, 1, 1, 1, 1, 1, 1, 1, 1) - end - assert_raises(DRb::DRbConnError) do - @there.sum('1' * 4096) - end - end - - def test_04 - assert_respond_to(@there, 'sum') - assert(!(@there.respond_to? "foobar")) - end - - def test_05_eq - a = @there.to_a[0] - b = @there.to_a[0] - assert(a.object_id != b.object_id) - assert(a == b) - assert_equal(a, b) - assert(a == @there) - assert_equal(a.hash, b.hash) - assert_equal(a.hash, @there.hash) - assert(a.eql?(b)) - assert(a.eql?(@there)) - end - - def test_06_timeout - ten = Onecky.new(10) - assert_raises(TimeoutError) do - @there.do_timeout(ten) - end - assert_raises(TimeoutError) do - @there.do_timeout(ten) - end - end - - def test_07_public_private_protected_missing - assert_nothing_raised() { - begin - @there.method_missing(:eval, 'nil') - rescue NoMethodError - assert_match(/^private method \`eval\'/, $!.message) - end - } - assert_nothing_raised() { - begin - @there.call_private_method - rescue NoMethodError - assert_equal(NoMethodError, $!.class) - assert_match(/^private method \`call_private_method\'/, $!.message) - end - } - assert_nothing_raised() { - begin - @there.call_protected_method - rescue NoMethodError - assert_equal(NoMethodError, $!.class) - assert_match(/^protected method \`call_protected_method\'/, $!.message) - end - } - assert_nothing_raised() { - begin - @there.method_missing(:undefined_method_test) - rescue NoMethodError - assert_equal(NoMethodError, $!.class) - assert_match(/^undefined method \`undefined_method_test\'/, $!.message) - end - } - assert_raises(DRb::DRbConnError) do - @there.method_missing(:__send__, :to_s) - end - assert_equal(true, @there.missing) - end - - def test_08_here - ro = DRbObject.new(nil, DRb.uri) - assert_kind_of(String, ro.to_s) - - ro = DRbObject.new_with_uri(DRb.uri) - assert_kind_of(String, ro.to_s) - end - - def uri_concat_option(uri, opt) - "#{uri}?#{opt}" - end - - def test_09_option - uri = uri_concat_option(@there.__drburi, "foo") - ro = DRbObject.new_with_uri(uri) - assert_equal(ro.__drburi, @there.__drburi) - assert_equal(3, ro.size) - - uri = uri_concat_option(@there.__drburi, "") - ro = DRbObject.new_with_uri(uri) - assert_equal(ro.__drburi, @there.__drburi) - assert_equal(DRb::DRbURIOption.new(''), ro.__drbref) - - uri = uri_concat_option(@there.__drburi, "hello?world") - ro = DRbObject.new_with_uri(uri) - assert_equal(DRb::DRbURIOption.new('hello?world'), ro.__drbref) - - uri = uri_concat_option(@there.__drburi, "?hello?world") - ro = DRbObject.new_with_uri(uri) - assert_equal(DRb::DRbURIOption.new('?hello?world'), ro.__drbref) - end - - def test_10_yield - @there.simple_hash.each do |k, v| - assert_kind_of(String, k) - assert_kind_of(Symbol, v) - end - end - - def test_10_yield_undumped - @there.xarray2_hash.each do |k, v| - assert_kind_of(String, k) - assert_kind_of(DRbObject, v) - end - end - - def test_11_remote_no_method_error - assert_raises(DRb::DRbRemoteError) do - @there.remote_no_method_error - end - begin - @there.remote_no_method_error - rescue - error = $! - assert_match(/^undefined method .*\(NoMethodError\)/, error.message) - assert_equal('NoMethodError', error.reason) - end - end -end - -module DRbAry - def setup - @ext = DRbService.ext_service('ut_array.rb') - @there = @ext.front - end - - def teardown - @ext.stop_service if @ext - end - - def test_01 - assert_kind_of(DRb::DRbObject, @there) - end - - def test_02_collect - ary = @there.collect do |x| x + x end - assert_kind_of(Array, ary) - assert_equal([2, 4, 'IIIIII', 8, 'fivefive', 12], ary) - end - - def test_03_redo - ary = [] - count = 0 - @there.each do |x| - count += 1 - ary.push x - redo if count == 3 - end - assert_equal([1, 2, 'III', 'III', 4, 'five', 6], ary) - end - - # retry in block is not supported on ruby 1.9 - #def test_04_retry - # retried = false - # ary = [] - # @there.each do |x| - # ary.push x - # if x == 4 && !retried - # retried = true - # retry - # end - # end - # assert_equal([1, 2, 'III', 4, 1, 2, 'III', 4, 'five', 6], ary) - #end - - def test_05_break - ary = [] - @there.each do |x| - ary.push x - break if x == 4 - end - assert_equal([1, 2, 'III', 4], ary) - end - - def test_06_next - ary = [] - @there.each do |x| - next if String === x - ary.push x - end - assert_equal([1, 2, 4, 6], ary) - end - - class_eval <<EOS - def test_07_break_18 - ary = [] - result = @there.each do |x| - ary.push x - break(:done) if x == 4 - end - assert_equal([1, 2, 'III', 4], ary) - assert_equal(:done, result) - end -EOS - -end diff --git a/trunk/test/drb/ignore_test_drb.rb b/trunk/test/drb/ignore_test_drb.rb deleted file mode 100644 index d0bb1f49b0..0000000000 --- a/trunk/test/drb/ignore_test_drb.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'drbtest' - -class TestDRbReusePort < Test::Unit::TestCase - include DRbAry - - def setup - @ext = DRbService.ext_service('ut_port.rb') - @there = @ext.front - end - - def teardown - return unless @ext - @ext.stop_service - while true - sleep 0.1 - begin - @ext.alive? - rescue DRb::DRbConnError - break - end - end - end -end - diff --git a/trunk/test/drb/test_acl.rb b/trunk/test/drb/test_acl.rb deleted file mode 100644 index d8955e0e75..0000000000 --- a/trunk/test/drb/test_acl.rb +++ /dev/null @@ -1,195 +0,0 @@ -# acltest.rb - ACL unit test -# Copyright (c) 2000 Masatoshi SEKI -# -# acltest.rb is copyrighted free software by Masatoshi SEKI. -# You can redistribute it and/or modify it under the same terms as Ruby. - -require 'test/unit' -require 'drb/acl' - -class SampleHosts - def initialize - list = %w(127.0.0.1 localhost - 192.168.1.1 x68k.linux.or.jp - 192.168.1.2 lc630.macos.or.jp - 192.168.1.3 lib30.win32.or.jp - 192.168.1.4 ns00.linux.or.jp - 192.168.1.5 yum.macos.or.jp - ::ffff:192.168.1.5 ipv6.macos.or.jp - ::192.168.1.5 too.yumipv6.macos.or.jp - 192.168.1.254 comstarz.foo.or.jp) - - @hostlist = Array.new(list.size / 2) - @hostlist.each_index do |idx| - @hostlist[idx] = ["AF_INET", 10000, list[idx * 2 + 1], list[idx * 2]] - end - - @hosts = Hash.new - @hostlist.each do |h| - @hosts[h[2].split('.')[0]] = h - end - end - attr_reader(:hostlist, :hosts) -end - - -class ACLEntryTest < Test::Unit::TestCase - HOSTS = SampleHosts.new - - def setup - @hostlist = HOSTS.hostlist - @hosts = HOSTS.hosts - end - - def test_all - a = ACL::ACLEntry.new("*") - b = ACL::ACLEntry.new("all") - @hostlist.each do |h| - assert(a.match(h)) - assert(b.match(h)) - end - end - - def test_ip_v6 - a = ACL::ACLEntry.new('::ffff:192.0.0.0/104') - assert(! a.match(@hosts['localhost'])) - assert(a.match(@hosts['yum'])) - assert(a.match(@hosts['ipv6'])) - assert(! a.match(@hosts['too'])) - end - - def test_ip - a = ACL::ACLEntry.new('192.0.0.0/8') - assert(! a.match(@hosts['localhost'])) - assert(a.match(@hosts['yum'])) - - a = ACL::ACLEntry.new('192.168.0.1/255.255.0.255') - assert(! a.match(@hosts['localhost'])) - assert(! a.match(@hosts['yum'])) - assert(a.match(@hosts['x68k'])) - - a = ACL::ACLEntry.new('192.168.1.0/24') - assert(! a.match(@hosts['localhost'])) - assert(a.match(@hosts['yum'])) - assert(a.match(@hosts['x68k'])) - - a = ACL::ACLEntry.new('92.0.0.0/8') - assert(! a.match(@hosts['localhost'])) - assert(! a.match(@hosts['yum'])) - assert(! a.match(@hosts['x68k'])) - - a = ACL::ACLEntry.new('127.0.0.1/255.0.0.255') - assert(a.match(@hosts['localhost'])) - assert(! a.match(@hosts['yum'])) - assert(! a.match(@hosts['x68k'])) - end - - def test_name - a = ACL::ACLEntry.new('*.jp') - assert(! a.match(@hosts['localhost'])) - assert(a.match(@hosts['yum'])) - - a = ACL::ACLEntry.new('yum.*.jp') - assert(a.match(@hosts['yum'])) - assert(! a.match(@hosts['lc630'])) - - a = ACL::ACLEntry.new('*.macos.or.jp') - assert(a.match(@hosts['yum'])) - assert(a.match(@hosts['lc630'])) - assert(! a.match(@hosts['lib30'])) - end -end - -class ACLListTest < Test::Unit::TestCase - HOSTS = SampleHosts.new - - def setup - @hostlist = HOSTS.hostlist - @hosts = HOSTS.hosts - end - - private - def build(list) - acl= ACL::ACLList.new - list.each do |s| - acl.add s - end - acl - end - - public - def test_all_1 - a = build(%w(all)) - @hostlist.each do |h| - assert(a.match(h)) - end - end - - def test_all_2 - a = build(%w(localhost 127.0.0.0/8 yum.* *)) - @hostlist.each do |h| - assert(a.match(h)) - end - end - - def test_1 - a = build(%w(192.0.0.1/255.0.0.255 yum.*.jp)) - assert(a.match(@hosts['yum'])) - assert(a.match(@hosts['x68k'])) - assert(! a.match(@hosts['lc630'])) - end - - def test_2 - a = build(%w(*.linux.or.jp)) - assert(!a.match(@hosts['yum'])) - assert(a.match(@hosts['x68k'])) - assert(!a.match(@hosts['lc630'])) - end -end - -class ACLTest < Test::Unit::TestCase - HOSTS = SampleHosts.new - - def setup - @hostlist = HOSTS.hostlist - @hosts = HOSTS.hosts - end - - def test_0 - a = ACL.new - @hostlist.each do |h| - assert(a.allow_addr?(h)) - end - end - - def test_not_0 - a = ACL.new([], ACL::ALLOW_DENY) - @hostlist.each do |h| - assert(! a.allow_addr?(h)) - end - end - - def test_1 - data = %w(deny all - allow localhost - allow x68k.*) - - a = ACL.new(data) - assert(a.allow_addr?(@hosts['x68k'])) - assert(a.allow_addr?(@hosts['localhost'])) - assert(! a.allow_addr?(@hosts['lc630'])) - end - - def test_not_1 - data = %w(deny 192.0.0.0/8 - allow localhost - allow x68k.*) - - a = ACL.new(data, ACL::ALLOW_DENY) - assert(!a.allow_addr?(@hosts['x68k'])) - assert(a.allow_addr?(@hosts['localhost'])) - assert(! a.allow_addr?(@hosts['lc630'])) - end -end - - diff --git a/trunk/test/drb/test_drb.rb b/trunk/test/drb/test_drb.rb deleted file mode 100644 index 106e958d9a..0000000000 --- a/trunk/test/drb/test_drb.rb +++ /dev/null @@ -1,301 +0,0 @@ -require 'drbtest' - -class TestDRbCore < Test::Unit::TestCase - include DRbCore -end - -class TestDRbYield < Test::Unit::TestCase - def setup - @ext = DRbService.ext_service('ut_drb.rb') - @there = @ext.front - end - - def teardown - @ext.stop_service if @ext - end - - def test_01_one - @there.echo_yield_1([]) {|one| - assert_equal([], one) - } - - @there.echo_yield_1(1) {|one| - assert_equal(1, one) - } - - @there.echo_yield_1(nil) {|one| - assert_equal(nil, one) - } - end - - def test_02_two - @there.echo_yield_2([], []) {|one, two| - assert_equal([], one) - assert_equal([], two) - } - - @there.echo_yield_2(1, 2) {|one, two| - assert_equal(1, one) - assert_equal(2, two) - } - - @there.echo_yield_2(3, nil) {|one, two| - assert_equal(3, one) - assert_equal(nil, two) - } - - @there.echo_yield_1([:key, :value]) {|one, two| - assert_equal(:key, one) - assert_equal(:value, two) - } - end - - def test_03_many - @there.echo_yield_0 {|*s| - assert_equal([], s) - } - @there.echo_yield(nil) {|*s| - assert_equal([nil], s) - } - @there.echo_yield(1) {|*s| - assert_equal([1], s) - } - @there.echo_yield(1, 2) {|*s| - assert_equal([1, 2], s) - } - @there.echo_yield(1, 2, 3) {|*s| - assert_equal([1, 2, 3], s) - } - @there.echo_yield([], []) {|*s| - assert_equal([[], []], s) - } - @there.echo_yield([]) {|*s| - assert_equal([[]], s) # ! - } - end - - def test_04_many_to_one - @there.echo_yield_0 {|*s| - assert_equal([], s) - } - @there.echo_yield(nil) {|*s| - assert_equal([nil], s) - } - @there.echo_yield(1) {|*s| - assert_equal([1], s) - } - @there.echo_yield(1, 2) {|*s| - assert_equal([1, 2], s) - } - @there.echo_yield(1, 2, 3) {|*s| - assert_equal([1, 2, 3], s) - } - @there.echo_yield([], []) {|*s| - assert_equal([[], []], s) - } - @there.echo_yield([]) {|*s| - assert_equal([[]], s) - } - end - - def test_05_array_subclass - @there.xarray_each {|x| assert_kind_of(XArray, x)} - @there.xarray_each {|*x| assert_kind_of(XArray, x[0])} - end - - def test_06_taint - x = proc {} - assert(! x.tainted?) - @there.echo_yield(x) {|o| - assert_equal(x, o) - assert(! x.tainted?) - } - end -end - -class TestDRbRubyYield < TestDRbYield - def echo_yield(*arg) - yield(*arg) - end - - def echo_yield_0 - yield - end - - def echo_yield_1(a) - yield(a) - end - - def echo_yield_2(a, b) - yield(a, b) - end - - def xarray_each - xary = [XArray.new([0])] - xary.each do |x| - yield(x) - end - end - - def setup - @there = self - end - - def teardown - end -end - -class TestDRbRuby18Yield < TestDRbRubyYield - class YieldTest18 - def echo_yield(*arg, &proc) - proc.call(*arg) - end - - def echo_yield_0(&proc) - proc.call - end - - def echo_yield_1(a, &proc) - proc.call(a) - end - - def echo_yield_2(a, b, &proc) - proc.call(a, b) - end - - def xarray_each(&proc) - xary = [XArray.new([0])] - xary.each(&proc) - end - - end - - def setup - @there = YieldTest18.new - end -end - -class TestDRbAry < Test::Unit::TestCase - include DRbAry -end - -class TestDRbMServer < Test::Unit::TestCase - def setup - @ext = DRbService.ext_service('ut_drb.rb') - @there = @ext.front - @server = (1..3).collect do |n| - DRb::DRbServer.new(nil, Onecky.new(n.to_s)) - end - end - - def teardown - @server.each do |s| - s.stop_service - end - @ext.stop_service if @ext - end - - def test_01 - assert_equal(6, @there.sample(@server[0].front, @server[1].front, @server[2].front)) - end -end - -class TestDRbSafe1 < TestDRbAry - def setup - @ext = DRbService.ext_service('ut_safe1.rb') - @there = @ext.front - end -end - -class TestDRbEval # < Test::Unit::TestCase - def setup - super - @ext = DRbService.ext_service('ut_eval.rb') - @there = @ext.front - end - - def teardown - @ext.stop_service if @ext - end - - def test_01_safe1_safe4_eval - assert_raises(SecurityError) do - @there.method_missing(:instance_eval, 'ENV.inspect') - end - - assert_raises(SecurityError) do - @there.method_missing(:send, :eval, 'ENV.inspect') - end - - remote_class = @there.remote_class - - assert_raises(SecurityError) do - remote_class.class_eval('ENV.inspect') - end - - assert_raises(SecurityError) do - remote_class.module_eval('ENV.inspect') - end - - four = @there.four - assert_equal(1, four.method_missing(:send, :eval, '1')) - - remote_class = four.remote_class - - assert_equal(1, remote_class.class_eval('1')) - - assert_equal(1, remote_class.module_eval('1')) - - assert_raises(SecurityError) do - remote_class.class_eval('ENV = {}') - end - - assert_raises(SecurityError) do - remote_class.module_eval('ENV = {}') - end - end -end - -class TestDRbLarge < Test::Unit::TestCase - def setup - @ext = DRbService.ext_service('ut_large.rb') - @there = @ext.front - end - - def teardown - @ext.stop_service if @ext - end - - def test_01_large_ary - ary = [2] * 10240 - assert_equal(10240, @there.size(ary)) - assert_equal(20480, @there.sum(ary)) - end - - def test_02_large_ary - ary = ["Hello, World"] * 10240 - assert_equal(10240, @there.size(ary)) - end - - def test_03_large_ary - ary = [Thread.current] * 10240 - assert_equal(10240, @there.size(ary)) - end - - def test_04_many_arg - assert_raises(ArgumentError) { - @there.arg_test(1, 2, 3, 4, 5, 6, 7, 8, 9, 0) - } - end - - def test_05_too_large_ary - ary = ["Hello, World"] * 102400 - exception = nil - begin - @there.size(ary) - rescue StandardError - exception = $! - end - assert_kind_of(StandardError, exception) - end -end diff --git a/trunk/test/drb/test_drbssl.rb b/trunk/test/drb/test_drbssl.rb deleted file mode 100644 index cfb3bc36a4..0000000000 --- a/trunk/test/drb/test_drbssl.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'drbtest' - -begin - require 'drb/ssl' -rescue LoadError -end - -if Object.const_defined?("OpenSSL") - - -class DRbSSLService < DRbService - %w(ut_drb_drbssl.rb ut_array_drbssl.rb).each do |nm| - add_service_command(nm) - end - config = Hash.new - - config[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER - config[:SSLVerifyCallback] = lambda{ |ok,x509_store| - true - } - begin - data = open("sample.key"){|io| io.read } - config[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(data) - data = open("sample.crt"){|io| io.read } - config[:SSLCertificate] = OpenSSL::X509::Certificate.new(data) - rescue - # $stderr.puts "Switching to use self-signed certificate" - config[:SSLCertName] = - [ ["C","JP"], ["O","Foo.DRuby.Org"], ["CN", "Sample"] ] - end - - uri = ARGV.shift if $0 == __FILE__ - @server = DRb::DRbServer.new(uri || 'drbssl://:0', self.manager, config) -end - -class TestDRbSSLCore < Test::Unit::TestCase - include DRbCore - def setup - @ext = DRbSSLService.ext_service('ut_drb_drbssl.rb') - @there = @ext.front - end - - def test_02_unknown - end - - def test_01_02_loop - end - - def test_05_eq - end -end - -class TestDRbSSLAry < Test::Unit::TestCase - include DRbAry - def setup - @ext = DRbSSLService.ext_service('ut_array_drbssl.rb') - @there = @ext.front - end -end - - -end diff --git a/trunk/test/drb/test_drbunix.rb b/trunk/test/drb/test_drbunix.rb deleted file mode 100644 index e1a17edd3d..0000000000 --- a/trunk/test/drb/test_drbunix.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'drbtest' - -begin - require 'drb/unix' -rescue LoadError -end - -if Object.const_defined?("UNIXServer") - - -class DRbUNIXService < DRbService - %w(ut_drb_drbunix.rb ut_array_drbunix.rb).each do |nm| - add_service_command(nm) - end - - uri = ARGV.shift if $0 == __FILE__ - @server = DRb::DRbServer.new(uri || 'drbunix:', self.manager, {}) -end - -class TestDRbUNIXCore < Test::Unit::TestCase - include DRbCore - def setup - @ext = DRbUNIXService.ext_service('ut_drb_drbunix.rb') - @there = @ext.front - end - - def test_02_unknown - end - - def test_01_02_loop - end - - def test_05_eq - end -end - -class TestDRbUNIXAry < Test::Unit::TestCase - include DRbAry - def setup - @ext = DRbUNIXService.ext_service('ut_array_drbunix.rb') - @there = @ext.front - end -end - - -end diff --git a/trunk/test/drb/ut_array.rb b/trunk/test/drb/ut_array.rb deleted file mode 100644 index 6d9778ffbc..0000000000 --- a/trunk/test/drb/ut_array.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'drb/drb' -require 'drb/extserv' - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <uri> <name>" unless it - it - end - - DRb.start_service(nil, [1, 2, 'III', 4, "five", 6]) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end - diff --git a/trunk/test/drb/ut_array_drbssl.rb b/trunk/test/drb/ut_array_drbssl.rb deleted file mode 100644 index 5644af5600..0000000000 --- a/trunk/test/drb/ut_array_drbssl.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'drb/drb' -require 'drb/extserv' -require 'drb/ssl' - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <uri> <name>" unless it - it - end - - config = Hash.new - config[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER - config[:SSLVerifyCallback] = lambda{|ok,x509_store| - true - } - config[:SSLCertName] = - [ ["C","JP"], ["O","Foo.DRuby.Org"], ["CN", "Sample"] ] - - DRb.start_service('drbssl://:0', [1, 2, 'III', 4, "five", 6], config) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end - diff --git a/trunk/test/drb/ut_array_drbunix.rb b/trunk/test/drb/ut_array_drbunix.rb deleted file mode 100644 index 76d2a610af..0000000000 --- a/trunk/test/drb/ut_array_drbunix.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'drb/drb' -require 'drb/extserv' - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <uri> <name>" unless it - it - end - - DRb.start_service('drbunix:', [1, 2, 'III', 4, "five", 6]) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end - diff --git a/trunk/test/drb/ut_drb.rb b/trunk/test/drb/ut_drb.rb deleted file mode 100644 index f5720cfca2..0000000000 --- a/trunk/test/drb/ut_drb.rb +++ /dev/null @@ -1,160 +0,0 @@ -require 'drb/drb' -require 'drb/extserv' -require 'timeout' - -class XArray < Array - def initialize(ary) - ary.each do |x| - self.push(x) - end - end -end - -class XArray2 < XArray - include DRbUndumped -end - -class Unknown2 - def initialize - @foo = 'unknown2' - end -end - -class DRbEx - include DRbUndumped - - class FooBar - def initialize - @foo = 'bar' - end - end - - class UError < RuntimeError; end - - def initialize - @hello = 'hello' - end - attr_reader :hello - - def sample(a, b, c) - a.to_i + b.to_i + c.to_i - end - - def sum(*a) - s = 0 - a.each do |e| - s += e.to_i - end - s - end - - def do_timeout(n) - timeout(0.1) do - n.sleep(2) - end - end - - def unknown_module - FooBar.new - end - - def unknown_class - Unknown2.new - end - - def unknown_error - raise UError - end - - def remote_no_method_error - invoke_no_method(self) - end - - def test_yield - yield - yield([]) - yield(*[]) - end - - def echo_yield(*arg) - yield(*arg) - nil - end - - def echo_yield_0 - yield - nil - end - - def echo_yield_1(one) - yield(one) - nil - end - - def echo_yield_2(one, two) - yield(one, two) - nil - end - - def xarray_each - xary = [XArray.new([0])] - xary.each do |x| - yield(x) - end - nil - end - - def xarray2_hash - unless @xary2_hash - @xary2_hash = { "a" => XArray2.new([0]), "b" => XArray2.new([1]) } - end - DRbObject.new(@xary2_hash) - end - - def simple_hash - unless @hash - @hash = { 'a'=>:a, 'b'=>:b } - end - DRbObject.new(@hash) - end - - def [](key) - key.to_s - end - - def to_a - [self] - end - - def method_missing(msg, *a, &b) - if msg == :missing - return true - else - super(msg, *a, &b) - end - end - - private - def call_private_method - true - end - - protected - def call_protected_method - true - end -end - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <manager-uri> <name>" unless it - it - end - - DRb::DRbServer.default_argc_limit(8) - DRb::DRbServer.default_load_limit(4096) - DRb.start_service('druby://localhost:0', DRbEx.new) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end diff --git a/trunk/test/drb/ut_drb_drbssl.rb b/trunk/test/drb/ut_drb_drbssl.rb deleted file mode 100644 index 0a2191e71a..0000000000 --- a/trunk/test/drb/ut_drb_drbssl.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "#{File.dirname(File.expand_path(__FILE__))}/ut_drb" -require 'drb/ssl' - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <manager-uri> <name>" unless it - it - end - - config = Hash.new - config[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER - config[:SSLVerifyCallback] = lambda{|ok,x509_store| - true - } - config[:SSLCertName] = - [ ["C","JP"], ["O","Foo.DRuby.Org"], ["CN", "Sample"] ] - - DRb::DRbServer.default_argc_limit(8) - DRb::DRbServer.default_load_limit(4096) - DRb.start_service('drbssl://localhost:0', DRbEx.new, config) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end - diff --git a/trunk/test/drb/ut_drb_drbunix.rb b/trunk/test/drb/ut_drb_drbunix.rb deleted file mode 100644 index 8b9484cf9c..0000000000 --- a/trunk/test/drb/ut_drb_drbunix.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "#{File.dirname(File.expand_path(__FILE__))}/ut_drb" - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <manager-uri> <name>" unless it - it - end - - DRb::DRbServer.default_argc_limit(8) - DRb::DRbServer.default_load_limit(4096) - DRb.start_service('drbunix:', DRbEx.new) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end - diff --git a/trunk/test/drb/ut_eval.rb b/trunk/test/drb/ut_eval.rb deleted file mode 100644 index 4df963e7cd..0000000000 --- a/trunk/test/drb/ut_eval.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'drb/drb' -require 'drb/extserv' - -class EvalAttack - def initialize - @four = DRb::DRbServer.new('druby://localhost:0', self, {:safe_level => 4}) - end - - def four - DRbObject.new_with_uri(@four.uri) - end - - def remote_class - DRbObject.new(self.class) - end -end - - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <uri> <name>" unless it - it - end - - $SAFE = 1 - - DRb.start_service('druby://localhost:0', EvalAttack.new, {:safe_level => 2}) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end diff --git a/trunk/test/drb/ut_large.rb b/trunk/test/drb/ut_large.rb deleted file mode 100644 index d6717c5589..0000000000 --- a/trunk/test/drb/ut_large.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'drb/drb' -require 'drb/extserv' -require 'timeout' - -class DRbLarge - include DRbUndumped - - def size(ary) - ary.size - end - - def sum(ary) - sum = 0 - ary.each do |e| - sum += e.to_i - end - sum - end - - def arg_test(*arg) - # nop - end -end - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <manager-uri> <name>" unless it - it - end - - DRb::DRbServer.default_argc_limit(3) - DRb::DRbServer.default_load_limit(100000) - DRb.start_service('druby://localhost:0', DRbLarge.new) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end - diff --git a/trunk/test/drb/ut_port.rb b/trunk/test/drb/ut_port.rb deleted file mode 100644 index 337e0eda86..0000000000 --- a/trunk/test/drb/ut_port.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'drb/drb' -require 'drb/extserv' - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <uri> <name>" unless it - it - end - - DRb.start_service('druby://:8473', [1, 2, 'III', 4, "five", 6]) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end diff --git a/trunk/test/drb/ut_safe1.rb b/trunk/test/drb/ut_safe1.rb deleted file mode 100644 index 4df8e1e5a1..0000000000 --- a/trunk/test/drb/ut_safe1.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'drb/drb' -require 'drb/extserv' - -if __FILE__ == $0 - def ARGV.shift - it = super() - raise "usage: #{$0} <uri> <name>" unless it - it - end - - DRb.start_service('druby://localhost:0', [1, 2, 'III', 4, "five", 6], - {:safe_level => 1}) - es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) - DRb.thread.join -end diff --git a/trunk/test/drb/ut_timerholder.rb b/trunk/test/drb/ut_timerholder.rb deleted file mode 100644 index 141cb73302..0000000000 --- a/trunk/test/drb/ut_timerholder.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'runit/testcase' -require 'runit/cui/testrunner' -require 'timerholder' - -class TimerHolderTest < RUNIT::TestCase - def do_test(timeout, keeper_sleep = nil) - holder = TimerHolder.new(timeout) - holder.keeper_sleep = keeper_sleep if keeper_sleep - key = holder.add(self) - sleep(timeout * 0.5) - assert_equal(holder.peek(key), self) - holder.delete(key) - assert(!holder.include?(key)) - key = holder.add(self) - sleep(timeout+0.5) - assert_equal(holder.fetch(key), nil) - key = holder.add(self) - assert_equal(holder.fetch(key), self) - holder.store(key, true) - assert_equal(holder.fetch(key), true) - assert_equal(holder.include?(key), true) - sleep(timeout+0.5) - assert_exception(TimerHolder::InvalidIndexError) do - holder.store(key, 1) - end - assert_equal(holder.include?(key), false) - key = holder.add(self) - sleep(timeout * 0.5) - assert(holder.include?(key)) - holder.extend(key, timeout) - sleep(timeout * 0.5) - assert(holder.include?(key)) - sleep(timeout * 0.6) - assert(!holder.include?(key)) - holder.delete(key) - end - - def test_00 - do_test(0.5) - end - - def test_01 - do_test(1, 0.5) - end -end - -if __FILE__ == $0 - RUNIT::CUI::TestRunner.run(TimerHolderTest.suite) -end |