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)
37 assert_instance_of Kgio::UNIXSocket, sock
38 ready = IO.select(nil, [ sock ])
39 assert_equal sock, ready[1][0]
40 assert_equal nil, sock.kgio_write("HELLO")
44 sock = Kgio::Socket.new(@addr)
45 assert_instance_of Kgio::Socket, sock
46 ready = IO.select(nil, [ sock ])
47 assert_equal sock, ready[1][0]
48 assert_equal nil, sock.kgio_write("HELLO")
52 sock = Kgio::Socket.start(@addr)
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 = SubSocket.start(@addr)
62 ready = IO.select(nil, [ sock ])
63 assert_equal sock, ready[1][0]
64 assert_equal nil, sock.kgio_write("HELLO")
67 def test_wait_writable_set
68 sock = SubSocket.new(@addr)
69 assert_kind_of Kgio::Socket, sock
70 assert_instance_of SubSocket, sock
71 assert_equal nil, sock.kgio_write("HELLO")