![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/lib/gems/2.5.0/gems/eventmachine-le-1.1.7/tests/ |
Upload File : |
require 'em_test_helper' class TestUDP46 < Test::Unit::TestCase # this is a bit brittle. Maybe do not test for the actual error... WANT_ALL = [ ( RUBY_PLATFORM =~ /darwin1/ and # not an error in Linux (!?), # strange handling in OSX 10.5.x (darwin9) ["::1", "::241.1.2.3", 5555, Errno::EHOSTUNREACH]), ["::1", "241.2.3.4", 5555, (RUBY_PLATFORM =~ /linux/ ? Errno::ENETUNREACH : Errno::EINVAL)], ["127.0.0.1", "241.4.5.6", 5555, (RUBY_PLATFORM =~ /linux/ ? Errno::EINVAL : Errno::ENETUNREACH)] ].compact # Open a UDP socket listening on, say, ::1, and try to send a UDP # datagram to IP address, say, ::241.1.2.3 (so no network route). # Without the error handling fix, it makes EM close the UDP socket. def test_udp_no_route WANT_ALL.each do |want| @@udp_socket_alive = false @@udp_socket_unbind_cause = nil @@error_came_in = false EM.run do EM::open_datagram_socket(want[0], next_port, EM::Connection) do |c| c.send_error_handling = :ERRORHANDLING_REPORT def c.unbind cause=nil @@udp_socket_unbind_cause = cause EM.stop end def c.receive_senderror(error, data) @@error_came_in = [error, data] end c.send_datagram "no-route", want[1], want[2] EM.add_timer(0.2) do @@udp_socket_alive = true unless c.error? EM.stop end end end assert @@udp_socket_alive, "UDP socket was killed (unbind cause: #{@@udp_socket_unbind_cause})" assert_equal [want[3], [want[1], want[2].to_s]], @@error_came_in end end end