eventmachine 0.12.0-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/COPYING +60 -0
  2. data/DEFERRABLES +138 -0
  3. data/EPOLL +141 -0
  4. data/GNU +281 -0
  5. data/KEYBOARD +38 -0
  6. data/LEGAL +25 -0
  7. data/LIGHTWEIGHT_CONCURRENCY +72 -0
  8. data/PURE_RUBY +77 -0
  9. data/README +74 -0
  10. data/RELEASE_NOTES +96 -0
  11. data/SMTP +9 -0
  12. data/SPAWNED_PROCESSES +93 -0
  13. data/TODO +10 -0
  14. data/ext/Makefile +180 -0
  15. data/ext/binder.cpp +126 -0
  16. data/ext/binder.h +48 -0
  17. data/ext/cmain.cpp +527 -0
  18. data/ext/cplusplus.cpp +172 -0
  19. data/ext/ed.cpp +1442 -0
  20. data/ext/ed.h +351 -0
  21. data/ext/em.cpp +1781 -0
  22. data/ext/em.h +167 -0
  23. data/ext/emwin.cpp +300 -0
  24. data/ext/emwin.h +94 -0
  25. data/ext/epoll.cpp +26 -0
  26. data/ext/epoll.h +25 -0
  27. data/ext/eventmachine.h +83 -0
  28. data/ext/eventmachine_cpp.h +94 -0
  29. data/ext/extconf.rb +203 -0
  30. data/ext/files.cpp +94 -0
  31. data/ext/files.h +65 -0
  32. data/ext/kb.cpp +368 -0
  33. data/ext/mkmf.log +129 -0
  34. data/ext/page.cpp +107 -0
  35. data/ext/page.h +51 -0
  36. data/ext/pipe.cpp +327 -0
  37. data/ext/project.h +119 -0
  38. data/ext/rubyeventmachine-i386-mswin32.def +2 -0
  39. data/ext/rubyeventmachine-i386-mswin32.exp +0 -0
  40. data/ext/rubyeventmachine-i386-mswin32.lib +0 -0
  41. data/ext/rubyeventmachine-i386-mswin32.pdb +0 -0
  42. data/ext/rubyeventmachine.so +0 -0
  43. data/ext/rubymain.cpp +630 -0
  44. data/ext/sigs.cpp +89 -0
  45. data/ext/sigs.h +32 -0
  46. data/ext/ssl.cpp +408 -0
  47. data/ext/ssl.h +86 -0
  48. data/ext/vc60.pdb +0 -0
  49. data/lib/em/deferrable.rb +208 -0
  50. data/lib/em/eventable.rb +39 -0
  51. data/lib/em/future.rb +62 -0
  52. data/lib/em/messages.rb +66 -0
  53. data/lib/em/processes.rb +68 -0
  54. data/lib/em/spawnable.rb +88 -0
  55. data/lib/em/streamer.rb +112 -0
  56. data/lib/eventmachine.rb +1621 -0
  57. data/lib/eventmachine_version.rb +31 -0
  58. data/lib/evma.rb +32 -0
  59. data/lib/evma/callback.rb +32 -0
  60. data/lib/evma/container.rb +75 -0
  61. data/lib/evma/factory.rb +77 -0
  62. data/lib/evma/protocol.rb +87 -0
  63. data/lib/evma/reactor.rb +48 -0
  64. data/lib/jeventmachine.rb +106 -0
  65. data/lib/pr_eventmachine.rb +1011 -0
  66. data/lib/protocols/buftok.rb +127 -0
  67. data/lib/protocols/header_and_content.rb +123 -0
  68. data/lib/protocols/httpcli2.rb +784 -0
  69. data/lib/protocols/httpclient.rb +253 -0
  70. data/lib/protocols/line_and_text.rb +122 -0
  71. data/lib/protocols/linetext2.rb +145 -0
  72. data/lib/protocols/saslauth.rb +179 -0
  73. data/lib/protocols/smtpclient.rb +308 -0
  74. data/lib/protocols/smtpserver.rb +543 -0
  75. data/lib/protocols/stomp.rb +127 -0
  76. data/lib/protocols/tcptest.rb +57 -0
  77. data/lib/rubyeventmachine.so +0 -0
  78. data/tests/test_basic.rb +142 -0
  79. data/tests/test_defer.rb +63 -0
  80. data/tests/test_epoll.rb +168 -0
  81. data/tests/test_errors.rb +82 -0
  82. data/tests/test_eventables.rb +78 -0
  83. data/tests/test_exc.rb +58 -0
  84. data/tests/test_futures.rb +214 -0
  85. data/tests/test_hc.rb +221 -0
  86. data/tests/test_httpclient.rb +194 -0
  87. data/tests/test_httpclient2.rb +133 -0
  88. data/tests/test_kb.rb +61 -0
  89. data/tests/test_ltp.rb +190 -0
  90. data/tests/test_ltp2.rb +261 -0
  91. data/tests/test_next_tick.rb +58 -0
  92. data/tests/test_processes.rb +56 -0
  93. data/tests/test_pure.rb +128 -0
  94. data/tests/test_running.rb +47 -0
  95. data/tests/test_sasl.rb +73 -0
  96. data/tests/test_send_file.rb +238 -0
  97. data/tests/test_servers.rb +90 -0
  98. data/tests/test_smtpclient.rb +81 -0
  99. data/tests/test_smtpserver.rb +93 -0
  100. data/tests/test_spawn.rb +329 -0
  101. data/tests/test_timers.rb +138 -0
  102. data/tests/test_ud.rb +43 -0
  103. data/tests/testem.rb +5 -0
  104. metadata +170 -0
@@ -0,0 +1,261 @@
1
+ # $Id: test_ltp2.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+ #
27
+
28
+ $:.unshift "../lib"
29
+ require 'eventmachine'
30
+ require 'test/unit'
31
+
32
+ # TODO!!! Need tests for overlength headers and text bodies.
33
+
34
+ class TestLineText2 < Test::Unit::TestCase
35
+
36
+ # Run each of these tests two ways: passing in the whole test-dataset in one chunk,
37
+ # and passing it in one character at a time.
38
+
39
+ class Basic
40
+ include EM::Protocols::LineText2
41
+ attr_reader :lines
42
+ def receive_line line
43
+ (@lines ||= []) << line
44
+ end
45
+ end
46
+ def test_basic
47
+ testdata = "Line 1\nLine 2\r\nLine 3\n"
48
+
49
+ a = Basic.new
50
+ a.receive_data testdata
51
+ assert_equal( ["Line 1", "Line 2", "Line 3"], a.lines )
52
+
53
+ a = Basic.new
54
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
55
+ assert_equal( ["Line 1", "Line 2", "Line 3"], a.lines )
56
+ end
57
+
58
+
59
+ class ChangeDelimiter
60
+ include EM::Protocols::LineText2
61
+ attr_reader :lines
62
+ def initialize *args
63
+ super
64
+ @delim = "A"
65
+ set_delimiter @delim
66
+ end
67
+ def receive_line line
68
+ (@lines ||= []) << line
69
+ set_delimiter( @delim.succ! )
70
+ end
71
+ end
72
+
73
+ def test_change_delimiter
74
+ testdata = %Q(LineaALinebBLinecCLinedD)
75
+
76
+ a = ChangeDelimiter.new
77
+ a.receive_data testdata
78
+ assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
79
+
80
+ a = ChangeDelimiter.new
81
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
82
+ assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
83
+ end
84
+
85
+
86
+ #--
87
+ # Test two lines followed by an empty line, ten bytes of binary data, then
88
+ # two more lines.
89
+
90
+ class Binary
91
+ include EM::Protocols::LineText2
92
+ attr_reader :lines, :body
93
+ def initialize *args
94
+ super
95
+ @lines = []
96
+ @body = nil
97
+ end
98
+ def receive_line ln
99
+ if ln == ""
100
+ set_text_mode 10
101
+ else
102
+ @lines << ln
103
+ end
104
+ end
105
+ def receive_binary_data data
106
+ @body = data
107
+ end
108
+ end
109
+
110
+ def test_binary
111
+ testdata = %Q(Line 1
112
+ Line 2
113
+
114
+ 0000000000Line 3
115
+ Line 4
116
+ )
117
+
118
+ a = Binary.new
119
+ a.receive_data testdata
120
+ assert_equal( ["Line 1", "Line 2", "Line 3", "Line 4"], a.lines)
121
+ assert_equal( "0000000000", a.body )
122
+
123
+ a = Binary.new
124
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
125
+ assert_equal( ["Line 1", "Line 2", "Line 3", "Line 4"], a.lines)
126
+ assert_equal( "0000000000", a.body )
127
+ end
128
+
129
+
130
+ # Test unsized binary data. The expectation is that each chunk of it
131
+ # will be passed to us as it it received.
132
+ class UnsizedBinary
133
+ include EM::Protocols::LineText2
134
+ attr_reader :n_calls, :body
135
+ def initialize *args
136
+ super
137
+ set_text_mode
138
+ end
139
+ def receive_binary_data data
140
+ @n_calls ||= 0
141
+ @n_calls += 1
142
+ (@body ||= "") << data
143
+ end
144
+ end
145
+
146
+ def test_unsized_binary
147
+ testdata = "X\0" * 1000
148
+
149
+ a = UnsizedBinary.new
150
+ a.receive_data testdata
151
+ assert_equal( 1, a.n_calls )
152
+ assert_equal( testdata, a.body )
153
+
154
+ a = UnsizedBinary.new
155
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
156
+ assert_equal( 2000, a.n_calls )
157
+ assert_equal( testdata, a.body )
158
+ end
159
+
160
+
161
+ # Test binary data with a "throw back" into line-mode.
162
+ class ThrowBack
163
+ include EM::Protocols::LineText2
164
+ attr_reader :headers
165
+ def initialize *args
166
+ super
167
+ @headers = []
168
+ @n_bytes = 0
169
+ set_text_mode
170
+ end
171
+ def receive_binary_data data
172
+ wanted = 25 - @n_bytes
173
+ will_take = if data.length > wanted
174
+ data.length - wanted
175
+ else
176
+ data.length
177
+ end
178
+ @n_bytes += will_take
179
+
180
+ if @n_bytes == 25
181
+ set_line_mode( data[will_take..-1] )
182
+ end
183
+ end
184
+ def receive_line ln
185
+ @headers << ln
186
+ end
187
+ end
188
+ def test_throw_back
189
+ testdata = "Line\n" * 10
190
+
191
+ a = ThrowBack.new
192
+ a.receive_data testdata
193
+ assert_equal( ["Line"] * 5, a.headers )
194
+
195
+ a = ThrowBack.new
196
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
197
+ assert_equal( ["Line"] * 5, a.headers )
198
+ end
199
+
200
+ # Test multi-character line delimiters.
201
+ # Also note that the test data has a "tail" with no delimiter, that will be
202
+ # discarded, but cf. the BinaryTail test.
203
+ # TODO!!! This test doesn't work in the byte-by-byte case.
204
+ class Multichar
205
+ include EM::Protocols::LineText2
206
+ attr_reader :lines
207
+ def initialize *args
208
+ super
209
+ @lines = []
210
+ set_delimiter "012"
211
+ end
212
+ def receive_line ln
213
+ @lines << ln
214
+ end
215
+ end
216
+ def test_multichar
217
+ testdata = "Line012Line012Line012Line"
218
+
219
+ a = Multichar.new
220
+ a.receive_data testdata
221
+ assert_equal( ["Line"]*3, a.lines )
222
+
223
+ a = Multichar.new
224
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
225
+ # DOESN'T WORK in this case. Multi-character delimiters are broken.
226
+ #assert_equal( ["Line"]*3, a.lines )
227
+ end
228
+
229
+ # Test a binary "tail," when a sized binary transfer doesn't complete because
230
+ # of an unbind. We get a partial result.
231
+ class BinaryTail
232
+ include EM::Protocols::LineText2
233
+ attr_reader :data
234
+ def initialize *args
235
+ super
236
+ @data = ""
237
+ set_text_mode 1000
238
+ end
239
+ def receive_binary_data data
240
+ # we expect to get all the data in one chunk, even in the byte-by-byte case,
241
+ # because sized transfers by definition give us exactly one call to
242
+ # #receive_binary_data.
243
+ @data = data
244
+ end
245
+ end
246
+ def test_binary_tail
247
+ testdata = "0" * 500
248
+
249
+ a = BinaryTail.new
250
+ a.receive_data testdata
251
+ a.unbind
252
+ assert_equal( "0" * 500, a.data )
253
+
254
+ a = BinaryTail.new
255
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
256
+ a.unbind
257
+ assert_equal( "0" * 500, a.data )
258
+ end
259
+
260
+ end
261
+
@@ -0,0 +1,58 @@
1
+ # $Id: test_next_tick.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+ #
27
+
28
+ $:.unshift "../lib"
29
+ require 'eventmachine'
30
+ require 'test/unit'
31
+
32
+
33
+
34
+ class TestNextTick < Test::Unit::TestCase
35
+
36
+ def setup
37
+ end
38
+
39
+ def teardown
40
+ end
41
+
42
+ def test_tick_arg
43
+ pr = proc {EM.stop}
44
+ EM.epoll
45
+ EM.run {
46
+ EM.next_tick pr
47
+ }
48
+ assert true
49
+ end
50
+
51
+ def test_tick_block
52
+ EM.epoll
53
+ EM.run {
54
+ EM.next_tick {EM.stop}
55
+ }
56
+ assert true
57
+ end
58
+ end
@@ -0,0 +1,56 @@
1
+ # $Id: test_processes.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'test/unit'
30
+
31
+ class TestProcesses < Test::Unit::TestCase
32
+
33
+ # EM::DeferrableChildProcess is a sugaring of a common use-case
34
+ # involving EM::popen.
35
+ # Call the #open method on EM::DeferrableChildProcess, passing
36
+ # a command-string. #open immediately returns an EM::Deferrable
37
+ # object. It also schedules the forking of a child process, which
38
+ # will execute the command passed to #open.
39
+ # When the forked child terminates, the Deferrable will be signalled
40
+ # and execute its callbacks, passing the data that the child process
41
+ # wrote to stdout.
42
+ #
43
+ def test_deferrable_child_process
44
+ ls = ""
45
+ EM.run {
46
+ d = EM::DeferrableChildProcess.open( "ls -ltr" )
47
+ d.callback {|data_from_child|
48
+ ls = data_from_child
49
+ EM.stop
50
+ }
51
+ }
52
+ assert( ls.length > 0)
53
+ end
54
+
55
+ end
56
+
@@ -0,0 +1,128 @@
1
+ # $Id: test_pure.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'test/unit'
30
+
31
+ class TestPure < Test::Unit::TestCase
32
+
33
+
34
+ Host,Port = "0.0.0.0", 9060
35
+
36
+
37
+ # These tests are intended to exercise problems that come up in the
38
+ # pure-Ruby implementation. However, we DON'T constrain them such that
39
+ # they only run in pure-Ruby. These tests need to work identically in
40
+ # any implementation.
41
+
42
+ def setup
43
+ end
44
+
45
+ def teardown
46
+ end
47
+
48
+ #-------------------------------------
49
+
50
+ # The EM reactor needs to run down open connections and release other resources
51
+ # when it stops running. Make sure this happens even if user code throws a Ruby
52
+ # exception.
53
+ # One way to see this is to run identical tests that open a TCP server and throw
54
+ # an exception. (We do this twice because an exception aborts a test. We make the
55
+ # two tests identical except for the method name because we can't predict the order
56
+ # in which the test harness will run them.)
57
+ # If exception handling is incorrect, the second test will fail with a no-bind error
58
+ # because the TCP server opened in the first test will not have been closed.
59
+ #
60
+ def run_exception
61
+ EM.run {
62
+ EM.start_server Host, Port
63
+ raise "an exception"
64
+ }
65
+ end
66
+ def test_exception_1
67
+ assert_raise( RuntimeError ) { run_exception }
68
+ end
69
+ def test_exception_2
70
+ assert_raise( RuntimeError ) { run_exception }
71
+ end
72
+
73
+
74
+
75
+ # Under some circumstances, the pure Ruby library would emit an Errno::ECONNREFUSED
76
+ # exception on certain kinds of TCP connect-errors.
77
+ # It's always been something of an open question whether EM should throw an exception
78
+ # in these cases but the defined answer has always been to catch it the unbind method.
79
+ # With a connect failure, the latter will always fire, but connection_completed will
80
+ # never fire. So even though the point is arguable, it's incorrect for the pure Ruby
81
+ # version to throw an exception.
82
+ module TestConnrefused
83
+ def unbind
84
+ EM.stop
85
+ end
86
+ def connection_completed
87
+ raise "should never get here"
88
+ end
89
+ end
90
+ def test_connrefused
91
+ EM.run {
92
+ EM.connect "0.0.0.0", 60001, TestConnrefused
93
+ }
94
+ end
95
+
96
+
97
+ # Make sure connection_completed gets called as expected with TCP clients. This is the
98
+ # opposite of test_connrefused.
99
+ # If the test fails, it will hang because EM.stop never gets called.
100
+ #
101
+ module TestConnaccepted
102
+ def connection_completed
103
+ EM.stop
104
+ end
105
+ end
106
+ def test_connaccepted
107
+ timeout = false
108
+ EM.run {
109
+ EM.start_server "0.0.0.0", 60002
110
+ EM.connect "0.0.0.0", 60002, TestConnaccepted
111
+ EM::Timer.new(1) {timeout = true; EM.stop}
112
+ }
113
+ assert_equal( false, timeout )
114
+ end
115
+
116
+
117
+
118
+ def test_reactor_running
119
+ a = false
120
+ EM.run {
121
+ a = EM.reactor_running?
122
+ EM.next_tick {EM.stop}
123
+ }
124
+ assert a
125
+ end
126
+
127
+
128
+ end