kgio 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ require './test/lib_server_accept'
2
+
3
+ class TestKgioTCPServer < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @host = ENV["TEST_HOST"] || '127.0.0.1'
7
+ @srv = Kgio::TCPServer.new(@host, 0)
8
+ @port = @srv.addr[1]
9
+ end
10
+
11
+ def client_connect
12
+ TCPSocket.new(@host, @port)
13
+ end
14
+
15
+ include LibServerAccept
16
+ end
@@ -0,0 +1,13 @@
1
+ require './test/lib_read_write'
2
+
3
+ class TesTcpServerReadClientWrite < Test::Unit::TestCase
4
+ def setup
5
+ @host = ENV["TEST_HOST"] || '127.0.0.1'
6
+ @srv = Kgio::TCPServer.new(@host, 0)
7
+ @port = @srv.addr[1]
8
+ @wr = Kgio::TCPSocket.new(@host, @port)
9
+ @rd = @srv.kgio_accept
10
+ end
11
+
12
+ include LibReadWriteTest
13
+ end
@@ -0,0 +1,17 @@
1
+ require './test/lib_read_write'
2
+ require 'tempfile'
3
+
4
+ class TestUnixServerReadClientWrite < Test::Unit::TestCase
5
+ def setup
6
+ tmp = Tempfile.new('kgio_unix')
7
+ @path = tmp.path
8
+ File.unlink(@path)
9
+ tmp.close rescue nil
10
+ @srv = Kgio::UNIXServer.new(@path)
11
+ @rd = Kgio::UNIXSocket.new(@path)
12
+ @wr = @srv.kgio_tryaccept
13
+ end
14
+
15
+ include LibReadWriteTest
16
+ end
17
+
@@ -0,0 +1,75 @@
1
+ require 'test/unit'
2
+ require 'io/nonblock'
3
+ $-w = true
4
+ require 'kgio'
5
+ require 'tempfile'
6
+
7
+ class SubSocket < Kgio::Socket
8
+ attr_accessor :foo
9
+ def wait_writable
10
+ @foo = "waited"
11
+ end
12
+ end
13
+
14
+ class TestKgioUnixConnect < Test::Unit::TestCase
15
+
16
+ def setup
17
+ tmp = Tempfile.new('kgio_unix')
18
+ @path = tmp.path
19
+ File.unlink(@path)
20
+ tmp.close rescue nil
21
+ @srv = Kgio::UNIXServer.new(@path)
22
+ @addr = Socket.pack_sockaddr_un(@path)
23
+ end
24
+
25
+ def teardown
26
+ @srv.close unless @srv.closed?
27
+ File.unlink(@path)
28
+ Kgio.accept_cloexec = true
29
+ end
30
+
31
+ def test_unix_socket_new_invalid
32
+ assert_raises(ArgumentError) { Kgio::UNIXSocket.new('*' * 1024 * 1024) }
33
+ end
34
+
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")
41
+ end
42
+
43
+ def test_new
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")
49
+ end
50
+
51
+ def test_start
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")
57
+ end
58
+
59
+ def test_socket_start
60
+ Kgio::wait_writable = :wait_writable
61
+ sock = SubSocket.start(@addr)
62
+ assert_nil sock.foo
63
+ ready = IO.select(nil, [ sock ])
64
+ assert_equal sock, ready[1][0]
65
+ assert_equal nil, sock.kgio_write("HELLO")
66
+ end
67
+
68
+ def test_wait_writable_set
69
+ Kgio::wait_writable = :wait_writable
70
+ sock = SubSocket.new(@addr)
71
+ assert_kind_of Kgio::Socket, sock
72
+ assert_instance_of SubSocket, sock
73
+ assert_equal nil, sock.kgio_write("HELLO")
74
+ end
75
+ end
@@ -0,0 +1,20 @@
1
+ require 'tempfile'
2
+ require './test/lib_server_accept'
3
+
4
+ class TestKgioUNIXServer < Test::Unit::TestCase
5
+
6
+ def setup
7
+ tmp = Tempfile.new('kgio_unix')
8
+ @path = tmp.path
9
+ File.unlink(@path)
10
+ tmp.close rescue nil
11
+ @srv = Kgio::UNIXServer.new(@path)
12
+ @host = '127.0.0.1'
13
+ end
14
+
15
+ def client_connect
16
+ UNIXSocket.new(@path)
17
+ end
18
+
19
+ include LibServerAccept
20
+ end
@@ -0,0 +1,17 @@
1
+ require './test/lib_read_write'
2
+ require 'tempfile'
3
+
4
+ class TestUnixServerReadClientWrite < Test::Unit::TestCase
5
+ def setup
6
+ tmp = Tempfile.new('kgio_unix')
7
+ @path = tmp.path
8
+ File.unlink(@path)
9
+ tmp.close rescue nil
10
+ @srv = Kgio::UNIXServer.new(@path)
11
+ @wr = Kgio::UNIXSocket.new(@path)
12
+ @rd = @srv.kgio_tryaccept
13
+ end
14
+
15
+ include LibReadWriteTest
16
+ end
17
+
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kgio
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
11
+ platform: ruby
12
+ authors:
13
+ - kgio hackers
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-28 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: |-
23
+ kgio provides non-blocking I/O methods for Ruby without raising
24
+ exceptions on EAGAIN and EINPROGRESS. It is intended for use with the
25
+ Unicorn and Rainbows! Rack servers, but may be used by other
26
+ applications.
27
+ email: mongrel-unicorn@rubyforge.org
28
+ executables: []
29
+
30
+ extensions:
31
+ - ext/kgio/extconf.rb
32
+ extra_rdoc_files:
33
+ - LICENSE
34
+ - README
35
+ - TODO
36
+ - NEWS
37
+ - ChangeLog
38
+ - ISSUES
39
+ - HACKING
40
+ - lib/kgio.rb
41
+ - ext/kgio/kgio_ext.c
42
+ files:
43
+ - .document
44
+ - .gitignore
45
+ - .manifest
46
+ - COPYING
47
+ - ChangeLog
48
+ - GIT-VERSION-FILE
49
+ - GIT-VERSION-GEN
50
+ - GNUmakefile
51
+ - HACKING
52
+ - ISSUES
53
+ - LICENSE
54
+ - NEWS
55
+ - README
56
+ - Rakefile
57
+ - TODO
58
+ - ext/kgio/extconf.rb
59
+ - ext/kgio/kgio_ext.c
60
+ - ext/kgio/missing/accept4.h
61
+ - ext/kgio/missing/ancient_ruby.h
62
+ - ext/kgio/my_fileno.h
63
+ - ext/kgio/nonblock.h
64
+ - ext/kgio/sock_for_fd.h
65
+ - kgio.gemspec
66
+ - lib/kgio.rb
67
+ - setup.rb
68
+ - test/lib_read_write.rb
69
+ - test/lib_server_accept.rb
70
+ - test/test_connect_fd_leak.rb
71
+ - test/test_pipe_popen.rb
72
+ - test/test_pipe_read_write.rb
73
+ - test/test_socketpair_read_write.rb
74
+ - test/test_tcp_client_read_server_write.rb
75
+ - test/test_tcp_connect.rb
76
+ - test/test_tcp_server.rb
77
+ - test/test_tcp_server_read_client_write.rb
78
+ - test/test_unix_client_read_server_write.rb
79
+ - test/test_unix_connect.rb
80
+ - test/test_unix_server.rb
81
+ - test/test_unix_server_read_client_write.rb
82
+ has_rdoc: true
83
+ homepage: http://unicorn.bogomips.org/kgio/
84
+ licenses: []
85
+
86
+ post_install_message:
87
+ rdoc_options:
88
+ - -t
89
+ - kinder, gentler I/O for Ruby
90
+ require_paths:
91
+ - lib
92
+ - ext
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ requirements: []
112
+
113
+ rubyforge_project: rainbows
114
+ rubygems_version: 1.3.7
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: kinder, gentler I/O for Ruby
118
+ test_files:
119
+ - test/test_unix_connect.rb
120
+ - test/test_pipe_read_write.rb
121
+ - test/test_unix_server.rb
122
+ - test/test_socketpair_read_write.rb
123
+ - test/test_tcp_server.rb
124
+ - test/test_unix_server_read_client_write.rb
125
+ - test/test_tcp_connect.rb
126
+ - test/test_connect_fd_leak.rb
127
+ - test/test_tcp_server_read_client_write.rb
128
+ - test/test_unix_client_read_server_write.rb
129
+ - test/test_tcp_client_read_server_write.rb
130
+ - test/test_pipe_popen.rb