aboutsummaryrefslogtreecommitdiffstats
path: root/toys/de/derb/drbssh_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'toys/de/derb/drbssh_test.rb')
-rw-r--r--toys/de/derb/drbssh_test.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/toys/de/derb/drbssh_test.rb b/toys/de/derb/drbssh_test.rb
new file mode 100644
index 0000000..8a1f2c2
--- /dev/null
+++ b/toys/de/derb/drbssh_test.rb
@@ -0,0 +1,68 @@
+$:.unshift File.dirname(__FILE__)
+
+require 'drbssh' # local version of drbssh sudo gem install drbssh
+
+class Ohmy
+ def toto
+ puts 'i am '+`hostname`
+ return 'i am '+`hostname`
+ end
+end
+
+# Connect - OK
+DRb.start_service 'drbssh://'
+remote = DRbObject.new_with_uri("drbssh://_sd/ruby")
+
+# Simple eval - OK
+puts remote.eval('`hostname`')
+puts remote.eval('1+1')
+
+# Send classobj - FAIL
+#o = DRbObject.new_with_uri "drbssh://_sd/ruby", Ohmy.new
+#Ohmy.new
+#o = remote.eval("Ohmy.new")
+#class << remote
+# undef :instance_eval
+# def bla
+# puts 'i am '+`hostname`
+# end
+#end
+#remote.bla
+
+# Create objects - OK
+#l = Hash
+#l2 = DRbObject.new(l, "drbssh://_sd/ruby")
+#remote_hash = remote.eval("@a = {}.extend(DRb::DRbUndumped)")
+#puts l2
+#remote_hash = remote.eval("@a = {}.extend(DRb::DRbUndumped)")
+
+# Send object - OK
+l = [1,2,3]
+obj = remote.eval("@data = \""+Marshal.dump(l)+"\"")
+obj = remote.eval("@a = Marshal.load(@data)")
+obj = remote.eval("@a += [4]")
+obj += [5]
+puts obj
+
+# Send class object - FAIL
+#o = Ohmy.new
+#eval("puts o.toto")
+#eval("puts Ohmy.new.toto")
+#eval("@c = \"Marshal.dump(Ohmy)\"; @d=Marshal.load(eval(@c))")
+#eval("@d.new.toto")
+#obj = remote.eval("@c = \""+Marshal.dump(Ohmy)+"\"")
+#puts obj
+#obj = remote.eval("@c.class")
+#puts obj
+#obj = remote.eval("@c.size")
+#puts obj
+#obj = remote.eval("@cc = Marshal.load(eval(@c))")
+#puts obj
+#obj = remote.eval("@o = @cc.new.toto")
+#puts obj
+#obj = remote.eval("@obj = @o.toto")
+#puts obj
+#obj = remote.eval("@obj = \""+Marshal.dump(o)+"\"")
+#puts obj
+#obj = remote.eval("puts Ohmy.new.toto")
+#puts obj