sensu-em 2.4.1-java → 2.5.0.beta-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +15 -5
- data/CHANGELOG.md +41 -1
- data/README.md +2 -3
- data/eventmachine.gemspec +2 -1
- data/ext/cmain.cpp +19 -3
- data/ext/ed.cpp +22 -8
- data/ext/em.cpp +123 -76
- data/ext/em.h +40 -6
- data/ext/eventmachine.h +2 -0
- data/ext/extconf.rb +16 -2
- data/ext/fastfilereader/extconf.rb +3 -0
- data/ext/fastfilereader/mapper.cpp +1 -1
- data/ext/project.h +11 -7
- data/ext/rubymain.cpp +38 -2
- data/ext/ssl.cpp +4 -1
- data/ext/ssl.h +4 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +8 -1
- data/lib/em/buftok.rb +34 -85
- data/lib/em/protocols/httpclient.rb +31 -11
- data/lib/em/protocols/line_and_text.rb +2 -3
- data/lib/em/protocols/linetext2.rb +0 -1
- data/lib/em/protocols/smtpserver.rb +32 -9
- data/lib/em/pure_ruby.rb +2 -2
- data/lib/em/tick_loop.rb +19 -19
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +12 -4
- data/lib/jeventmachine.rb +22 -6
- data/lib/rubyeventmachine.jar +0 -0
- data/rakelib/package.rake +1 -1
- data/tests/em_test_helper.rb +4 -0
- data/tests/test_attach.rb +1 -0
- data/tests/test_basic.rb +14 -16
- data/tests/test_completion.rb +1 -0
- data/tests/test_connection_count.rb +1 -0
- data/tests/test_connection_write.rb +35 -0
- data/tests/test_epoll.rb +11 -14
- data/tests/test_httpclient.rb +43 -0
- data/tests/test_iterator.rb +6 -6
- data/tests/test_kb.rb +19 -25
- data/tests/test_many_fds.rb +22 -0
- data/tests/test_pause.rb +7 -2
- data/tests/test_pool.rb +2 -0
- data/tests/test_process_watch.rb +2 -0
- data/tests/test_processes.rb +7 -7
- data/tests/test_resolver.rb +33 -7
- data/tests/test_ssl_methods.rb +3 -4
- data/tests/test_ssl_verify.rb +62 -62
- data/tests/test_threaded_resource.rb +8 -0
- data/tmp/java/rubyeventmachine/.build +0 -0
- metadata +27 -10
@@ -227,18 +227,26 @@ module EventMachine
|
|
227
227
|
process_unknown
|
228
228
|
end
|
229
229
|
end
|
230
|
-
|
230
|
+
|
231
231
|
# TODO - implement this properly, the implementation is a stub!
|
232
|
-
def
|
232
|
+
def process_help
|
233
233
|
send_data "250 Ok, but unimplemented\r\n"
|
234
234
|
end
|
235
|
+
|
236
|
+
# RFC2821, 3.5.3 Meaning of VRFY or EXPN Success Response:
|
237
|
+
# A server MUST NOT return a 250 code in response to a VRFY or EXPN
|
238
|
+
# command unless it has actually verified the address. In particular,
|
239
|
+
# a server MUST NOT return 250 if all it has done is to verify that the
|
240
|
+
# syntax given is valid. In that case, 502 (Command not implemented)
|
241
|
+
# or 500 (Syntax error, command unrecognized) SHOULD be returned.
|
242
|
+
#
|
235
243
|
# TODO - implement this properly, the implementation is a stub!
|
236
|
-
def
|
237
|
-
send_data "
|
244
|
+
def process_vrfy
|
245
|
+
send_data "502 Command not implemented\r\n"
|
238
246
|
end
|
239
247
|
# TODO - implement this properly, the implementation is a stub!
|
240
248
|
def process_expn
|
241
|
-
send_data "
|
249
|
+
send_data "502 Command not implemented\r\n"
|
242
250
|
end
|
243
251
|
|
244
252
|
#--
|
@@ -358,12 +366,23 @@ module EventMachine
|
|
358
366
|
def process_auth_line(line)
|
359
367
|
plain = line.unpack("m").first
|
360
368
|
_,user,psw = plain.split("\000")
|
361
|
-
|
369
|
+
|
370
|
+
succeeded = proc {
|
362
371
|
send_data "235 authentication ok\r\n"
|
363
372
|
@state << :auth
|
364
|
-
|
373
|
+
}
|
374
|
+
failed = proc {
|
365
375
|
send_data "535 invalid authentication\r\n"
|
376
|
+
}
|
377
|
+
auth = receive_plain_auth user,psw
|
378
|
+
|
379
|
+
if auth.respond_to?(:callback)
|
380
|
+
auth.callback(&succeeded)
|
381
|
+
auth.errback(&failed)
|
382
|
+
else
|
383
|
+
(auth ? succeeded : failed).call
|
366
384
|
end
|
385
|
+
|
367
386
|
@state.delete :auth_incomplete
|
368
387
|
end
|
369
388
|
|
@@ -409,8 +428,12 @@ module EventMachine
|
|
409
428
|
#--
|
410
429
|
# STARTTLS may not be issued before EHLO, or unless the user has chosen
|
411
430
|
# to support it.
|
412
|
-
# TODO, must support user-supplied certificates.
|
413
431
|
#
|
432
|
+
# If :starttls_options is present and :starttls is set in the parms
|
433
|
+
# pass the options in :starttls_options to start_tls. Do this if you want to use
|
434
|
+
# your own certificate
|
435
|
+
# e.g. {:cert_chain_file => "/etc/ssl/cert.pem", :private_key_file => "/etc/ssl/private/cert.key"}
|
436
|
+
|
414
437
|
def process_starttls
|
415
438
|
if @@parms[:starttls]
|
416
439
|
if @state.include?(:starttls)
|
@@ -419,7 +442,7 @@ module EventMachine
|
|
419
442
|
send_data "503 EHLO required before STARTTLS\r\n"
|
420
443
|
else
|
421
444
|
send_data "220 Start TLS negotiation\r\n"
|
422
|
-
start_tls
|
445
|
+
start_tls(@@parms[:starttls_options] || {})
|
423
446
|
@state << :starttls
|
424
447
|
end
|
425
448
|
else
|
data/lib/em/pure_ruby.rb
CHANGED
@@ -393,7 +393,7 @@ module EventMachine
|
|
393
393
|
100.times {
|
394
394
|
@loopbreak_port = rand(10000) + 40000
|
395
395
|
begin
|
396
|
-
@loopbreak_reader.bind "
|
396
|
+
@loopbreak_reader.bind "127.0.0.1", @loopbreak_port
|
397
397
|
bound = true
|
398
398
|
break
|
399
399
|
rescue
|
@@ -410,7 +410,7 @@ module EventMachine
|
|
410
410
|
|
411
411
|
def signal_loopbreak
|
412
412
|
#@loopbreak_writer.write '+' if @loopbreak_writer
|
413
|
-
@loopbreak_writer.send('+',0,"
|
413
|
+
@loopbreak_writer.send('+',0,"127.0.0.1",@loopbreak_port) if @loopbreak_writer
|
414
414
|
end
|
415
415
|
|
416
416
|
def set_timer_quantum interval_in_seconds
|
data/lib/em/tick_loop.rb
CHANGED
@@ -7,25 +7,25 @@ module EventMachine
|
|
7
7
|
# A TickLoop is useful when one needs to distribute amounts of work
|
8
8
|
# throughout ticks in order to maintain response times. It is also useful for
|
9
9
|
# simple repeated checks and metrics.
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
10
|
+
# @example
|
11
|
+
# # Here we run through an array one item per tick until it is empty,
|
12
|
+
# # printing each element.
|
13
|
+
# # When the array is empty, we return :stop from the callback, and the
|
14
|
+
# # loop will terminate.
|
15
|
+
# # When the loop terminates, the on_stop callbacks will be called.
|
16
|
+
# EM.run do
|
17
|
+
# array = (1..100).to_a
|
18
|
+
#
|
19
|
+
# tickloop = EM.tick_loop do
|
20
|
+
# if array.empty?
|
21
|
+
# :stop
|
22
|
+
# else
|
23
|
+
# puts array.shift
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# tickloop.on_stop { EM.stop }
|
28
|
+
# end
|
29
29
|
#
|
30
30
|
class TickLoop
|
31
31
|
|
data/lib/em/version.rb
CHANGED
data/lib/eventmachine.rb
CHANGED
@@ -966,13 +966,16 @@ module EventMachine
|
|
966
966
|
callback = @next_tick_mutex.synchronize { @next_tick_queue.shift }
|
967
967
|
begin
|
968
968
|
callback.call
|
969
|
+
rescue
|
970
|
+
exception_raised = true
|
971
|
+
raise
|
969
972
|
ensure
|
970
973
|
# This is a little nasty. The problem is, if an exception occurs during
|
971
974
|
# the callback, then we need to send a signal to the reactor to actually
|
972
975
|
# do some work during the next_tick. The only mechanism we have from the
|
973
976
|
# ruby side is next_tick itself, although ideally, we'd just drop a byte
|
974
977
|
# on the loopback descriptor.
|
975
|
-
EM.next_tick {} if
|
978
|
+
EM.next_tick {} if exception_raised
|
976
979
|
end
|
977
980
|
end
|
978
981
|
end
|
@@ -1042,7 +1045,12 @@ module EventMachine
|
|
1042
1045
|
thread = Thread.new do
|
1043
1046
|
Thread.current.abort_on_exception = true
|
1044
1047
|
while true
|
1045
|
-
|
1048
|
+
begin
|
1049
|
+
op, cback = *@threadqueue.pop
|
1050
|
+
rescue ThreadError
|
1051
|
+
$stderr.puts $!.message
|
1052
|
+
break # Ruby 2.0 may fail at Queue.pop
|
1053
|
+
end
|
1046
1054
|
result = op.call
|
1047
1055
|
@resultqueue << [result, cback]
|
1048
1056
|
EventMachine.signal_loopbreak
|
@@ -1528,9 +1536,9 @@ module EventMachine
|
|
1528
1536
|
raise ArgumentError, "must provide module or subclass of #{klass.name}" unless klass >= handler
|
1529
1537
|
handler
|
1530
1538
|
elsif handler
|
1531
|
-
|
1539
|
+
if defined?(handler::EM_CONNECTION_CLASS)
|
1532
1540
|
handler::EM_CONNECTION_CLASS
|
1533
|
-
|
1541
|
+
else
|
1534
1542
|
handler::const_set(:EM_CONNECTION_CLASS, Class.new(klass) {include handler})
|
1535
1543
|
end
|
1536
1544
|
else
|
data/lib/jeventmachine.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
5
5
|
# Date:: 8 Apr 2006
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# See EventMachine and EventMachine::Connection for documentation and
|
8
8
|
# usage examples.
|
9
9
|
#
|
@@ -11,17 +11,17 @@
|
|
11
11
|
#
|
12
12
|
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
13
|
# Gmail: blackhedd
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# This program is free software; you can redistribute it and/or modify
|
16
16
|
# it under the terms of either: 1) the GNU General Public License
|
17
17
|
# as published by the Free Software Foundation; either version 2 of the
|
18
18
|
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# See the file COPYING for complete licensing information.
|
21
21
|
#
|
22
22
|
#---------------------------------------------------------------------------
|
23
23
|
#
|
24
|
-
#
|
24
|
+
#
|
25
25
|
|
26
26
|
# This module provides "glue" for the Java version of the EventMachine reactor core.
|
27
27
|
# For C++ EventMachines, the analogous functionality is found in ext/rubymain.cpp,
|
@@ -269,8 +269,21 @@ module EventMachine
|
|
269
269
|
@em.getConnectionCount
|
270
270
|
end
|
271
271
|
|
272
|
+
def self.pause_connection(sig)
|
273
|
+
@em.pauseConnection(sig)
|
274
|
+
end
|
275
|
+
def self.resume_connection(sig)
|
276
|
+
@em.resumeConnection(sig)
|
277
|
+
end
|
278
|
+
def self.connection_paused?(sig)
|
279
|
+
@em.isConnectionPaused(sig)
|
280
|
+
end
|
281
|
+
def self._get_outbound_data_size(sig)
|
282
|
+
@em.getOutboundDataSize(sig)
|
283
|
+
end
|
284
|
+
|
272
285
|
def self.set_tls_parms(sig, privkeyfile, certchainfile, verify_peer, use_tls, cipher_list)
|
273
|
-
keystore = KeyStoreBuilder.create privkeyfile, certchainfile unless (privkeyfile.empty? or certchainfile.empty?)
|
286
|
+
keystore = KeyStoreBuilder.create privkeyfile, certchainfile unless (privkeyfile.empty? or certchainfile.empty?)
|
274
287
|
@em.setTlsParms(sig, keystore, (!!verify_peer))
|
275
288
|
end
|
276
289
|
def self.send_file_data(sig, filename)
|
@@ -280,6 +293,9 @@ module EventMachine
|
|
280
293
|
def associate_callback_target sig
|
281
294
|
# No-op for the time being
|
282
295
|
end
|
296
|
+
def get_outbound_data_size
|
297
|
+
EM._get_outbound_data_size @signature
|
298
|
+
end
|
283
299
|
end
|
284
300
|
end
|
285
301
|
|
@@ -305,7 +321,7 @@ module KeyStoreBuilder
|
|
305
321
|
|
306
322
|
def self.create(privkeyfile, certchainfile)
|
307
323
|
self.init
|
308
|
-
|
324
|
+
|
309
325
|
key_reader = FileReader.new privkeyfile
|
310
326
|
key_pair = PEMReader.new(key_reader).read_object
|
311
327
|
|
data/lib/rubyeventmachine.jar
CHANGED
Binary file
|
data/rakelib/package.rake
CHANGED
data/tests/em_test_helper.rb
CHANGED
data/tests/test_attach.rb
CHANGED
data/tests/test_basic.rb
CHANGED
@@ -179,18 +179,15 @@ class TestBasic < Test::Unit::TestCase
|
|
179
179
|
assert x
|
180
180
|
end
|
181
181
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
end
|
192
|
-
else
|
193
|
-
warn "EM.set_heartbeat_interval not implemented, skipping a test in #{__FILE__}"
|
182
|
+
def test_set_heartbeat_interval
|
183
|
+
omit_if(jruby?)
|
184
|
+
interval = 0.5
|
185
|
+
EM.run {
|
186
|
+
EM.set_heartbeat_interval interval
|
187
|
+
$interval = EM.get_heartbeat_interval
|
188
|
+
EM.stop
|
189
|
+
}
|
190
|
+
assert_equal(interval, $interval)
|
194
191
|
end
|
195
192
|
|
196
193
|
module PostInitRaiser
|
@@ -226,6 +223,7 @@ class TestBasic < Test::Unit::TestCase
|
|
226
223
|
end
|
227
224
|
|
228
225
|
def test_schedule_close
|
226
|
+
omit_if(jruby?)
|
229
227
|
localhost, port = '127.0.0.1', 9000
|
230
228
|
timer_ran = false
|
231
229
|
num_close_scheduled = nil
|
@@ -247,22 +245,22 @@ class TestBasic < Test::Unit::TestCase
|
|
247
245
|
end
|
248
246
|
|
249
247
|
def test_fork_safe
|
250
|
-
|
248
|
+
omit_if(jruby?)
|
249
|
+
omit_if(rbx?, 'Omitting test on Rubinius because it hangs for unknown reasons')
|
251
250
|
|
252
251
|
read, write = IO.pipe
|
253
252
|
EM.run do
|
254
|
-
|
253
|
+
fork do
|
255
254
|
write.puts "forked"
|
256
255
|
EM.run do
|
257
256
|
EM.next_tick do
|
258
257
|
write.puts "EM ran"
|
259
|
-
|
258
|
+
EM.stop
|
260
259
|
end
|
261
260
|
end
|
262
261
|
end
|
263
262
|
EM.stop
|
264
263
|
end
|
265
|
-
Process.waitall
|
266
264
|
assert_equal "forked\n", read.readline
|
267
265
|
assert_equal "EM ran\n", read.readline
|
268
266
|
ensure
|
data/tests/test_completion.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
|
3
|
+
class TestConnectionWrite < Test::Unit::TestCase
|
4
|
+
|
5
|
+
# This test takes advantage of the fact that EM::_RunSelectOnce iterates over the connections twice:
|
6
|
+
# - once to determine which ones to call Write() on
|
7
|
+
# - and once to call Write() on each of them.
|
8
|
+
#
|
9
|
+
# But state may change in the meantime before Write() is finally called.
|
10
|
+
# And that is what we try to exploit to get Write() to be called when bWatchOnly is true, and bNotifyWritable is false,
|
11
|
+
# to cause an assertion failure.
|
12
|
+
|
13
|
+
module SimpleClient
|
14
|
+
def notify_writable
|
15
|
+
$conn2.notify_writable = false # Being naughty in callback
|
16
|
+
# If this doesn't crash anything, the test passed!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_with_naughty_callback
|
21
|
+
EM.run do
|
22
|
+
r1, w1 = IO.pipe
|
23
|
+
r2, w2 = IO.pipe
|
24
|
+
|
25
|
+
# Adding EM.watches
|
26
|
+
$conn1 = EM.watch(r1, SimpleClient)
|
27
|
+
$conn2 = EM.watch(r2, SimpleClient)
|
28
|
+
|
29
|
+
$conn1.notify_writable = true
|
30
|
+
$conn2.notify_writable = true
|
31
|
+
|
32
|
+
EM.stop
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/tests/test_epoll.rb
CHANGED
@@ -25,19 +25,16 @@ class TestEpoll < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
a = EM.set_descriptor_table_size( 1024 )
|
39
|
-
assert( a == 1024 )
|
40
|
-
end
|
28
|
+
# We can set the rlimit/nofile of a process but we can only set it
|
29
|
+
# higher if we're running as root.
|
30
|
+
# On most systems, the default value is 1024.
|
31
|
+
def test_rlimit
|
32
|
+
omit_if(windows? || jruby?)
|
33
|
+
unless EM.set_descriptor_table_size >= 1024
|
34
|
+
a = EM.set_descriptor_table_size
|
35
|
+
assert( a <= 1024 )
|
36
|
+
a = EM.set_descriptor_table_size( 1024 )
|
37
|
+
assert( a == 1024 )
|
41
38
|
end
|
42
39
|
end
|
43
40
|
|
@@ -97,7 +94,7 @@ class TestEpoll < Test::Unit::TestCase
|
|
97
94
|
assert_equal( "abcdefghij", $out )
|
98
95
|
end
|
99
96
|
|
100
|
-
# XXX this test fails randomly
|
97
|
+
# XXX this test fails randomly...
|
101
98
|
def _test_unix_domain
|
102
99
|
fn = "/tmp/xxx.chain"
|
103
100
|
EM.epoll
|
data/tests/test_httpclient.rb
CHANGED
@@ -187,4 +187,47 @@ class TestHttpClient < Test::Unit::TestCase
|
|
187
187
|
assert ok
|
188
188
|
end
|
189
189
|
|
190
|
+
#-----------------------------------------
|
191
|
+
|
192
|
+
# Test a server that returns chunked encoding
|
193
|
+
#
|
194
|
+
class ChunkedEncodingContent < EventMachine::Connection
|
195
|
+
def initialize *args
|
196
|
+
super
|
197
|
+
end
|
198
|
+
def receive_data data
|
199
|
+
send_data ["HTTP/1.1 200 OK",
|
200
|
+
"Server: nginx/0.7.67",
|
201
|
+
"Date: Sat, 23 Oct 2010 16:41:32 GMT",
|
202
|
+
"Content-Type: application/json",
|
203
|
+
"Transfer-Encoding: chunked",
|
204
|
+
"Connection: keep-alive",
|
205
|
+
"",
|
206
|
+
"1800",
|
207
|
+
"chunk1" * 1024,
|
208
|
+
"5a",
|
209
|
+
"chunk2" * 15,
|
210
|
+
"0",
|
211
|
+
""].join("\r\n")
|
212
|
+
close_connection_after_writing
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_http_chunked_encoding_content
|
217
|
+
ok = false
|
218
|
+
EventMachine.run {
|
219
|
+
EventMachine.start_server "127.0.0.1", 9701, ChunkedEncodingContent
|
220
|
+
c = EventMachine::Protocols::HttpClient.send :request, :host => "127.0.0.1", :port => 9701
|
221
|
+
c.callback {|result|
|
222
|
+
if result[:content] == "chunk1" * 1024 + "chunk2" * 15
|
223
|
+
ok = true
|
224
|
+
end
|
225
|
+
EventMachine.stop
|
226
|
+
}
|
227
|
+
}
|
228
|
+
assert ok
|
229
|
+
end
|
230
|
+
|
190
231
|
end
|
232
|
+
|
233
|
+
|
data/tests/test_iterator.rb
CHANGED
@@ -18,7 +18,7 @@ class TestIterator < Test::Unit::TestCase
|
|
18
18
|
}, proc {EM.stop})
|
19
19
|
}
|
20
20
|
assert_equal(10, items.keys.size)
|
21
|
-
assert_equal(
|
21
|
+
assert_equal(list.to_a.sort, items.values.flatten.sort)
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_concurrency_bigger_than_list_size
|
@@ -33,7 +33,7 @@ class TestIterator < Test::Unit::TestCase
|
|
33
33
|
}, proc {EM.stop})
|
34
34
|
}
|
35
35
|
assert_equal(1, items.keys.size)
|
36
|
-
assert_equal(
|
36
|
+
assert_equal(list.to_a.sort, items.values.flatten.sort)
|
37
37
|
end
|
38
38
|
|
39
39
|
|
@@ -56,7 +56,7 @@ class TestIterator < Test::Unit::TestCase
|
|
56
56
|
}
|
57
57
|
}
|
58
58
|
assert_equal(9, items.keys.size)
|
59
|
-
assert_equal(
|
59
|
+
assert_equal(list.to_a.sort, items.values.flatten.sort)
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_map
|
@@ -65,7 +65,7 @@ class TestIterator < Test::Unit::TestCase
|
|
65
65
|
EM::Iterator.new(list).map(proc{ |num,iter|
|
66
66
|
EM.add_timer(0.01){ iter.return(num) }
|
67
67
|
}, proc{ |results|
|
68
|
-
assert_equal(
|
68
|
+
assert_equal(list.to_a.size, results.size)
|
69
69
|
EM.stop
|
70
70
|
})
|
71
71
|
}
|
@@ -80,7 +80,7 @@ class TestIterator < Test::Unit::TestCase
|
|
80
80
|
iter.return(hash)
|
81
81
|
}
|
82
82
|
}, proc{ |results|
|
83
|
-
assert_equal(results.keys, list)
|
83
|
+
assert_equal(results.keys.sort, list.sort)
|
84
84
|
EM.stop
|
85
85
|
})
|
86
86
|
}
|
@@ -94,4 +94,4 @@ class TestIterator < Test::Unit::TestCase
|
|
94
94
|
EM.stop
|
95
95
|
}
|
96
96
|
end
|
97
|
-
end
|
97
|
+
end
|
data/tests/test_kb.rb
CHANGED
@@ -2,33 +2,27 @@ require 'em_test_helper'
|
|
2
2
|
|
3
3
|
class TestKeyboardEvents < Test::Unit::TestCase
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
EM::stop if d == "STOP"
|
10
|
-
end
|
5
|
+
module KbHandler
|
6
|
+
include EM::Protocols::LineText2
|
7
|
+
def receive_line d
|
8
|
+
EM::stop if d == "STOP"
|
11
9
|
end
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
else
|
27
|
-
warn "EM.open_keyboard not implemented, skipping tests in #{__FILE__}"
|
28
|
-
|
29
|
-
# Because some rubies will complain if a TestCase class has no tests
|
30
|
-
def test_em_open_keyboard_unsupported
|
31
|
-
assert true
|
12
|
+
# This test doesn't actually do anything useful but is here to
|
13
|
+
# illustrate the usage. If you removed the timer and ran this test
|
14
|
+
# by itself on a console, and then typed into the console, it would
|
15
|
+
# work.
|
16
|
+
# I don't know how to get the test harness to simulate actual keystrokes.
|
17
|
+
# When someone figures that out, then we can make this a real test.
|
18
|
+
#
|
19
|
+
def test_kb
|
20
|
+
omit_if(jruby?)
|
21
|
+
omit_if(!$stdout.tty?) # don't run the test unless it stands a chance of validity.
|
22
|
+
EM.run do
|
23
|
+
EM.open_keyboard KbHandler
|
24
|
+
EM::Timer.new(1) { EM.stop }
|
32
25
|
end
|
33
26
|
end
|
27
|
+
|
34
28
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
class TestManyFDs < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@port = next_port
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_connection_class_cache
|
10
|
+
mod = Module.new
|
11
|
+
a = nil
|
12
|
+
Process.setrlimit(Process::RLIMIT_NOFILE,4096);
|
13
|
+
EM.run {
|
14
|
+
EM.start_server '127.0.0.1', @port, mod
|
15
|
+
1100.times do
|
16
|
+
a = EM.connect '127.0.0.1', @port, mod
|
17
|
+
assert_kind_of EM::Connection, a
|
18
|
+
end
|
19
|
+
EM.stop
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
data/tests/test_pause.rb
CHANGED
@@ -82,14 +82,19 @@ class TestPause < Test::Unit::TestCase
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
buf = 'a' * 1024
|
86
|
+
|
85
87
|
EM.run do
|
86
88
|
EM.start_server "127.0.0.1", @port, test_server
|
87
89
|
cli = EM.connect "127.0.0.1", @port
|
88
|
-
|
90
|
+
128.times do
|
91
|
+
cli.send_data buf
|
92
|
+
end
|
89
93
|
end
|
90
94
|
|
91
95
|
assert_equal 1, incoming.size
|
92
|
-
|
96
|
+
assert incoming[0].bytesize > buf.bytesize
|
97
|
+
assert incoming[0].bytesize < buf.bytesize * 128
|
93
98
|
end
|
94
99
|
else
|
95
100
|
warn "EM.pause_connection not implemented, skipping tests in #{__FILE__}"
|
data/tests/test_pool.rb
CHANGED