7 class SubSocket < Kgio::Socket
14 class TestKgioUnixConnect < Test::Unit::TestCase
17 tmp = Tempfile.new('kgio_unix')
21 @srv = Kgio::UNIXServer.new(@path)
22 @addr = Socket.pack_sockaddr_un(@path)
26 @srv.close unless @srv.closed?
28 Kgio.accept_cloexec = true
31 def test_unix_socket_new_invalid
32 assert_raises(ArgumentError) { Kgio::UNIXSocket.new('*' * 1024 * 1024) }
35 def test_unix_socket_new
36 sock = Kgio::UNIXSocket.new(@path)
38 sock.respond_to?(:close_on_exec?) and
39 assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?)
41 assert_instance_of Kgio::UNIXSocket, sock
42 ready = IO.select(nil, [ sock ])
43 assert_equal sock, ready[1][0]
44 assert_equal nil, sock.kgio_write("HELLO")
48 sock = Kgio::Socket.new(@addr)
50 sock.respond_to?(:close_on_exec?) and
51 assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?)
53 assert_instance_of Kgio::Socket, sock
54 ready = IO.select(nil, [ sock ])
55 assert_equal sock, ready[1][0]
56 assert_equal nil, sock.kgio_write("HELLO")
60 sock = Kgio::Socket.start(@addr)
61 assert_instance_of Kgio::Socket, sock
62 ready = IO.select(nil, [ sock ])
63 assert_equal sock, ready[1][0]
64 assert_equal nil, sock.kgio_write("HELLO")
68 sock = SubSocket.start(@addr)
70 ready = IO.select(nil, [ sock ])
71 assert_equal sock, ready[1][0]
72 assert_equal nil, sock.kgio_write("HELLO")
75 def test_wait_writable_set
76 sock = SubSocket.new(@addr)
77 assert_kind_of Kgio::Socket, sock
78 assert_instance_of SubSocket, sock
79 assert_equal nil, sock.kgio_write("HELLO")