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")
51 def test_wait_writable_set
52 Kgio::wait_writable = :wait_writable
53 sock = SubSocket.new(@addr)
54 assert_kind_of Kgio::Socket, sock
55 assert_instance_of SubSocket, sock
56 assert_equal nil, sock.kgio_write("HELLO")