Skip to content

Commit

Permalink
Windows / MinGW test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Jun 29, 2017
1 parent 7ab23fc commit 42e75e9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
9 changes: 7 additions & 2 deletions spec/nio/selectables/pipe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@
# will throw EAGAIN if there is too little space to write the string
# TODO: Use FFI to lookup the platform-specific size of PIPE_BUF
str = "JUNK IN THE TUBES" * 10_000
cntr = 0
begin
pipe.write_nonblock str
_, writers = select [], [pipe], [], 0
cntr += 1
t = select [], [pipe], [], 0
rescue Errno::EPIPE
break
end while writers && writers.include?(pipe)
rescue IO::EWOULDBLOCKWaitWritable
skip "windows - can't test due to 'select' not showing correct status"
break
end while t && t[1].include?(pipe) && cntr < 20

pipe
end
Expand Down
15 changes: 8 additions & 7 deletions spec/nio/selectables/ssl_socket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
cert.issuer = name
cert.subject = name
cert.not_before = Time.now
cert.not_after = Time.now + (365 * 24 * 60 * 60)
cert.not_after = Time.now + (7 * 24 * 60 * 60)
cert.public_key = ssl_key.public_key

cert.sign(ssl_key, OpenSSL::Digest::SHA1.new)
cert.sign(ssl_key, OpenSSL::Digest::SHA256.new)
end
end

Expand Down Expand Up @@ -111,14 +111,17 @@
ssl_peer.accept
thread.join

cntr = 0
begin
_, writers = select [], [ssl_client], [], 0
count = ssl_client.write_nonblock "X" * 1024
expect(count).not_to eq(0)
cntr += 1
t = select [], [ssl_client], [], 0
rescue IO::WaitReadable, IO::WaitWritable
pending "SSL will report writable but not accept writes"
raise if writers.include? ssl_client
end while writers && writers.include?(ssl_client)
end while t && t[1].include?(ssl_client) && cntr < 30



# I think the kernel might manage to drain its buffer a bit even after
# the socket first goes unwritable. Attempt to sleep past this and then
Expand All @@ -141,8 +144,6 @@
end

let :pair do
pending "figure out why newly created sockets are selecting readable immediately"

server = TCPServer.new(addr, port)
client = TCPSocket.new(addr, port)
peer = server.accept
Expand Down
12 changes: 11 additions & 1 deletion spec/nio/selectables/udp_socket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@
end

let :writable_subject do
pending "come up with a writable UDPSocket example"
peer = UDPSocket.new
peer.connect "localhost", udp_port
cntr = 0
begin
peer.send("X" * 1024, 0)
cntr += 1
t = select [], [peer], [], 0
rescue
pending "UDPSocket Error"
end while t && t[1].include?(peer) && cntr < 5
peer
end

let :unwritable_subject do
Expand Down
3 changes: 0 additions & 3 deletions spec/support/selectable_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
let(:peer) { pair.last }

it "selects readable when the other end closes" do
# hax: this test is broken for OpenSSL sockets
skip "broken for SSL ;_;" if peer.is_a? OpenSSL::SSL::SSLSocket

monitor = selector.register(stream, :r)
expect(selector.select(0)).to be_nil

Expand Down

0 comments on commit 42e75e9

Please sign in to comment.