tests: remove tests for IO#nonblock? after accept
[kgio.git] / test / test_accept_flags.rb
blob0f21adfae34a0031dcc16d97a52e37f44f2ef579
1 require 'test/unit'
2 require 'fcntl'
3 require 'io/nonblock'
4 $-w = true
5 require 'kgio'
7 class TestAcceptFlags < Test::Unit::TestCase
8   def test_accept_flags
9     @host = ENV["TEST_HOST"] || '127.0.0.1'
10     @srv = Kgio::TCPServer.new(@host, 0)
11     @port = @srv.addr[1]
13     client = TCPSocket.new(@host, @port)
14     accepted = @srv.kgio_accept(nil, Kgio::SOCK_NONBLOCK)
15     assert_instance_of Kgio::Socket, accepted
16     flags = accepted.fcntl(Fcntl::F_GETFD)
17     assert_equal 0, flags & Fcntl::FD_CLOEXEC
18     assert_nil client.close
19     assert_nil accepted.close
21     client = TCPSocket.new(@host, @port)
22     accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC)
23     assert_instance_of Kgio::Socket, accepted
24     flags = accepted.fcntl(Fcntl::F_GETFD)
25     assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
26     assert_nil client.close
27     assert_nil accepted.close
29     client = TCPSocket.new(@host, @port)
30     accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC|Kgio::SOCK_NONBLOCK)
31     assert_instance_of Kgio::Socket, accepted
32     flags = accepted.fcntl(Fcntl::F_GETFD)
33     assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
34     assert_nil client.close
35     assert_nil accepted.close
37     client = TCPSocket.new(@host, @port)
38     accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC|Kgio::SOCK_NONBLOCK)
39     assert_instance_of Kgio::Socket, accepted
40     flags = accepted.fcntl(Fcntl::F_GETFD)
41     assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
42     assert_nil client.close
43     assert_nil accepted.close
44   end
45 end