initial commit + release
[kgio.git] / test / test_unix_server.rb
blob91b91b8737b6912ee2121e22040f7cfc74dd1fff
1 require 'test/unit'
2 require 'io/nonblock'
3 $-w = true
4 require 'kgio'
5 require 'tempfile'
7 class TestKgioUNIXServer < Test::Unit::TestCase
9   def setup
10     tmp = Tempfile.new('kgio_unix')
11     @path = tmp.path
12     File.unlink(@path)
13     tmp.close rescue nil
14     @srv = Kgio::UNIXServer.new(@path)
15   end
17   def teardown
18     @srv.close unless @srv.closed?
19     File.unlink(@path)
20     Kgio.accept_cloexec = true
21   end
23   def test_accept
24     a = UNIXSocket.new(@path)
25     b = @srv.kgio_accept
26     assert_kind_of Kgio::Socket, b
27     assert_equal "127.0.0.1", b.kgio_addr
28   end
30   def test_accept_nonblock
31     @srv.nonblock = true
32     assert_equal nil, @srv.kgio_accept
33   end
34 end