Guest User

Untitled

a guest
Apr 26th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. Both of the OOB tests fail in JRuby but pass in MRI and Rubinius (all on linux only). I'm not 100% sure that I've specified the OOB behaviour correctly (but I think so!). Is this a JRuby/Java bug?
  2.  
  3. Can someone have a look and let me know what they think, please?
  4.  
  5.  
  6. require File.dirname(__FILE__) + '/../../../spec_helper'
  7. require File.dirname(__FILE__) + '/../fixtures/classes'
  8.  
  9. describe "BasicSocket#recv" do
  10. it "receives a message from another socket" do
  11. # TCPServer and TCPSocket both inherit from BasicSocket
  12. server = TCPServer.new('127.0.0.1', SocketSpecs.port)
  13. data = nil
  14. t = Thread.new do
  15. client = server.accept
  16. data = client.recv(5)
  17. client.close
  18. end
  19. Thread.pass until t.status == "sleep"
  20. socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
  21. socket.send('hello', 0).should == 5
  22. t.join
  23. data.should == 'hello'
  24. socket.close
  25. server.close
  26. end
  27.  
  28. it "accepts flags to specify unusual receiving behaviour" do
  29. server = TCPServer.new('127.0.0.1', SocketSpecs.port)
  30. data = nil
  31. t = Thread.new do
  32. client = server.accept
  33. data = client.recv(5, Socket::MSG_OOB)
  34. client.close
  35. end
  36. Thread.pass until t.status == "sleep"
  37. socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
  38. socket.send('helloU', Socket::MSG_OOB)
  39. t.join
  40. data.should == 'U'
  41. socket.close
  42. server.close
  43. end
  44. end
  45.  
  46. ----------------
  47.  
  48. require File.dirname(__FILE__) + '/../../../spec_helper'
  49. require File.dirname(__FILE__) + '/../fixtures/classes'
  50.  
  51. describe "BasicSocket#send" do
  52. it "sends a message to another socket and returns the number of bytes sent" do
  53. # TCPSocket inherits from BasicSocket
  54. server = TCPServer.new('127.0.0.1', SocketSpecs.port)
  55. data = nil
  56. t = Thread.new do
  57. client = server.accept
  58. data = client.recv(5)
  59. client.close
  60. end
  61. Thread.pass until t.status == "sleep"
  62. socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
  63. socket.send('hello', 0).should == 5
  64. t.join
  65. data.should == 'hello'
  66. socket.close
  67. server.close
  68. end
  69.  
  70. it "accepts flags to specify unusual sending behaviour" do
  71. server = TCPServer.new('127.0.0.1', SocketSpecs.port)
  72. data = nil
  73. t = Thread.new do
  74. client = server.accept
  75. data = client.recv(6)
  76. client.close
  77. end
  78. Thread.pass until t.status == "sleep"
  79. socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
  80. socket.send('helloU', Socket::MSG_OOB).should == 6
  81. t.join
  82. data.should == 'hello'
  83. socket.close
  84. server.close
  85. end
  86. end
Add Comment
Please, Sign In to add comment