Sha256: 975dc1a1005b570110d6d9178d445915b73bbb62576977878ad0bd2f371cd8d9

Contents?: true

Size: 1.5 KB

Versions: 22

Compression:

Stored size: 1.5 KB

Contents

require 'test/unit'
require 'fcntl'
require 'io/nonblock'
$-w = true
require 'kgio'

class TestAcceptFlags < Test::Unit::TestCase
  def test_accept_flags
    @host = ENV["TEST_HOST"] || '127.0.0.1'
    @srv = Kgio::TCPServer.new(@host, 0)
    @port = @srv.addr[1]

    client = TCPSocket.new(@host, @port)
    accepted = @srv.kgio_accept(nil, Kgio::SOCK_NONBLOCK)
    assert_instance_of Kgio::Socket, accepted
    flags = accepted.fcntl(Fcntl::F_GETFD)
    assert_equal 0, flags & Fcntl::FD_CLOEXEC
    assert_nil client.close
    assert_nil accepted.close

    client = TCPSocket.new(@host, @port)
    accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC)
    assert_instance_of Kgio::Socket, accepted
    flags = accepted.fcntl(Fcntl::F_GETFD)
    assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
    assert_nil client.close
    assert_nil accepted.close

    client = TCPSocket.new(@host, @port)
    accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC|Kgio::SOCK_NONBLOCK)
    assert_instance_of Kgio::Socket, accepted
    flags = accepted.fcntl(Fcntl::F_GETFD)
    assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
    assert_nil client.close
    assert_nil accepted.close

    client = TCPSocket.new(@host, @port)
    accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC|Kgio::SOCK_NONBLOCK)
    assert_instance_of Kgio::Socket, accepted
    flags = accepted.fcntl(Fcntl::F_GETFD)
    assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
    assert_nil client.close
    assert_nil accepted.close
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
kgio-2.11.4 test/test_accept_flags.rb
kgio-2.11.3 test/test_accept_flags.rb
kgio-2.11.2 test/test_accept_flags.rb
kgio-2.11.1.1.g36ea test/test_accept_flags.rb
kgio-2.11.1 test/test_accept_flags.rb
kgio-2.11.0 test/test_accept_flags.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/kgio-2.10.0/test/test_accept_flags.rb
kgio-2.10.0 test/test_accept_flags.rb
kgio-2.9.3 test/test_accept_flags.rb
kgio-2.9.2 test/test_accept_flags.rb
kgio-2.9.1 test/test_accept_flags.rb
kgio-2.9.0.2.gf33a test/test_accept_flags.rb
kgio-2.9.0 test/test_accept_flags.rb
kgio-2.8.1 test/test_accept_flags.rb
kgio-2.8.0.2.g30c1 test/test_accept_flags.rb
kgio-2.8.0 test/test_accept_flags.rb
kgio-2.7.4 test/test_accept_flags.rb
kgio-2.7.3 test/test_accept_flags.rb
kgio-2.7.2 test/test_accept_flags.rb
kgio-2.7.1 test/test_accept_flags.rb