raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
blob ef84e05bed6cee1a9b30313e03c7852250b2cae6 1515 bytes (raw)
name: test/test_last_data_recv.rb 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
require 'test/unit'
require 'raindrops'
require 'io/wait'

class TestLastDataRecv < Test::Unit::TestCase
  def test_accept_nonblock_agg
    s = Socket.new(:INET, :STREAM, 0)
    s.listen(128)
    addr = s.connect_address
    s.extend(Raindrops::Aggregate::LastDataRecv)
    s.raindrops_aggregate = []
    c = Socket.new(:INET, :STREAM, 0)
    c.connect(addr)
    c.write '.' # for TCP_DEFER_ACCEPT
    client, ai = s.accept_nonblock(exception: false)
    assert client.kind_of?(Socket)
    assert ai.kind_of?(Addrinfo)
    assert_equal 1, s.raindrops_aggregate.size
    assert s.raindrops_aggregate[0].instance_of?(Integer)
    client, ai = s.accept_nonblock(exception: false)
    assert_equal :wait_readable, client
    assert_nil ai
    assert_equal 1, s.raindrops_aggregate.size
    assert_raise(IO::WaitReadable) { s.accept_nonblock }
  end

  def test_accept_nonblock_one
    s = TCPServer.new('127.0.0.1', 0)
    s.extend(Raindrops::Aggregate::LastDataRecv)
    s.raindrops_aggregate = []
    addr = s.addr
    c = TCPSocket.new(addr[3], addr[1])
    c.write '.' # for TCP_DEFER_ACCEPT
    client = s.accept_nonblock(exception: false)
    assert client.kind_of?(TCPSocket)
    assert_equal 1, s.raindrops_aggregate.size
    assert s.raindrops_aggregate[0].instance_of?(Integer)
    client = s.accept_nonblock(exception: false)
    assert_equal :wait_readable, client
    assert_equal 1, s.raindrops_aggregate.size
    assert_raise(IO::WaitReadable) { s.accept_nonblock }
  end
end if RUBY_PLATFORM =~ /linux/

debug log:

solving ef84e05 ...
found ef84e05 in https://yhbt.net/raindrops.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/raindrops.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).