about summary refs log tree commit homepage
path: root/test
DateCommit message (Collapse)
2019-12-14test_syssend: avoid warning on cleanup
We don't want to clutter up logs with warnings for cross-thread IO#close
2019-12-14test_connect_fd_leak: do not close socket if non-existent
2019-10-30tests: fix unused variable warnings from newer Rubies
Newer Rubies warn about more things...
2019-10-28test: fix warnings with RUBYOPT=-w
2016-12-16test: increase test data sizes to fill socket buffers
Some Debian build machines use insanely large socket buffers, so increase our test buffers to large values to force EAGAIN: https://bugs.debian.org/830353 In my experience, using setsockopt to clamp buffers to small sizes can lead to unpredictable stalls, too, so it might not be good to do in a test case, either.
2016-12-15reinstate the original (and dangerous) autopush in C
The regression for existing users was unnacceptable and completely poor judgement on my part. This change brings us back to potentially not-future-compatible code which will impose maintenance burdens on us in the face of future Ruby changes. But TODAY, it is the most performant option for folks who need to use autopush. Revert "resurrect Kgio.autopush support in pure Ruby" and "remove autopush support and make it a no-op" This reverts commits 64dc570f4b99f68b5ed792b36e7e8abc3df74927 and 4347980fa66115425fa8b765353c8b1bfe5dec24.
2015-10-09resurrect Kgio.autopush support in pure Ruby
This avoids breaking compatibility for existing apps, but is less performant (although safer and more resilient to future changes in Ruby) than the previous C version.
2015-08-13remove autopush support and make it a no-op
Maintaining global state in a library like kgio is ugly, and it is not optimal from a performance standpoint compared to using MSG_MORE. TCP_CORK and TCP_NOPUSH require extra syscalls so it still offers sub-optimal performance compared to MSG_MORE. Instead, server developers should use MSG_MORE if their OS supports it (and should add MSG_MORE to their OS if lacking it).
2014-04-09test/lib_read_write: fix trywritev blocking test
penultimate return value may be a subarray for writev-related routines, not a string. Caught by a pre-upload check by Christian Hofstaedtler on the debian-ruby list for kgio 2.9.1 Tested-by: Christian Hofstaedtler <zeha@debian.org> Cc: Hleb Valoshka <375gnu@gmail.com> Cc: <debian-ruby@lists.debian.org> Cc: Yura Sokolov <funny.falcon@gmail.com>
2014-02-05only define and test kgio_syssend on 1.9+
Reported-by: Christopher Rigor <crigor@gmail.com>
2014-02-04add kgio_syssend method to wrap send(2)
This behaves like kgio_trywrite on GNU/Linux, but allows extra flags to be specified. The main purpose of this is to support use of the MSG_MORE flag on GNU/Linux.
2013-09-25test_poll: remove race prone test_poll_EINTR_changed test
We haven't figured out a way to reliably test this w/o races, so lets just remove it for now and trust it works by reading the C code. ref: <CAAB-KcnpvcG6=OZNsBmvv440OHfCWs6-eDD7L6oD=ziCRXPHLA@mail.gmail.com>
2013-09-07Close tempfile and unlink it immediately.
When a Tempfile object is garbage collected, or when the Ruby interpreter exits, its associated temporary file is automatically deleted. This may lead to race condition when Tempfile is used like in these tests. Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-09-05test_poll: be less dependent on signal handler ordering
Just spam the thread several times to force the wakeup to happen and not be as dependent on signal handler execution ordering of different Ruby VMs. Tested-by: Hleb Valoshka <375gnu@gmail.com>
2013-09-04Create own directory for every unix socket in unit tests
[ew: this avoids a TOCTOU issue for multiple test invocations] Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-09-03test_poll: preserve original trap(:USR1) handler
The existing SIGUSR1 handler may not always be "DEFAULT", so restore the original one.
2013-09-03test_poll: avoid potentially thread-unsafe test
Modifying pollset in a different pollset is thread-unsafe, so just do that inside the signal handler as that should fire before restarting poll().
2013-09-03test/lib_read_write: account for larger-than-normal pipes
Linux pipe buffers may use larger pages and increase the capacity of pipes. Thus the 10000 write attempt is not sufficient; just infinite loop until we hit :wait_writable.
2013-09-03test_tryopen: skip EACCES test when euid == 0
This fails when the test is run as root (which may be the case of some Ruby installations) or fakeroot (which is the case of Debian build systems).
2013-09-02Don't dump 20M in case of failure
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-09-02Change prefix of temporary sockets to prevent races
Note: this is an incomplete fix and the race can still happen. A proper fix would involve using a temporary directory for each test and placing the Unix socket in there. Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-01-18rename fastopen => kgio_fastopen in Kgio::Socket
In the unlikely case the Ruby Socket class implements its own "fastopen" method, we will avoid conflicting.
2012-12-27implement TCP Fast Open support (client + server)
Server support just requires exposing one constant for setsockopt: Kgio::TCP_FASTOPEN Client support implements a new Kgio::Socket#fastopen method. This new method wraps the the sendto() syscall. With TCP Fast Open, the sendto() syscall is overloaded for stream sockets to implement the functionality of both connect() + write() Since it only makes sense to use _blocking_ I/O for sendto(), TFO clients are only supported in Ruby implementations with native threads.
2012-12-13Kgio::Socket.new retains compatibility with Socket.new
This allows us to create an unconnected socket, just like the normal Socket class it inherits from.
2012-07-11test workaround for platforms with unreliable signals
Ruby may not respond well to signals on all platforms, especially not after fork()-ing in the face of a running pthread (timer thread on 1.9.2). SIGKILL bypasses Ruby (and all userspace) signal handling on Debian GNU/kFreeBSD.
2012-07-11test/lib_read_write: wait for readability before tryread
On FreeBSD, writing to a loopback TCP socket does not guarantee immediate readability on the other end. Tested on Debian GNU/kFreeBSD 6.0
2012-07-11test_poll: skip signal torture on Debian GNU/kfreebsd
This cascades test failures on a platform with questionable signal/fork handling. Tested on: Debian GNU/kFreeBSD 6.0
2012-06-01add `#kgio_writev` and `#kgio_trywritev`
Add methods for using writev(2) syscall for sending array of string in a single syscall. This is more efficient than concatenating strings on Ruby side or sending them one by one. `#kgio_trywritev` returns array of strings which are not sent to the socket. If there were objects other than string, they could be converted using `#to_s` method, but this is not strictly applied, cause `#kgio_*writev` tries to write at most `sysconf(_SC_IOV_MAX)` items at once (for Linux its value is 1024). First string of returned array could be part of string from array, so that you should assume it is not in consistent state. `#kgio_writev` semantic differs a bit from `#kgio_write` in term of buffers mutability: currently `#kgio_write` tries to follow string changes made concurrently, but `#kgio_writev` works with array's lightweight copy. Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-05-30Fix UnixClientReadServerWrite test class name
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-03-24test: more workaround for FreeBSD 9.0
Followup-to: e26358413c9d87e1ce8f6cda5cf0b8dd53979ed2
2012-03-23test/lib_read_write: test workarounds for TCP in FreeBSD 9.0
Under load, TCP sockets may not register as readable right away after the writer finishes. This can be expected for implementations where loopback TCP is a closer simulation of non-local TCP traffic. These test failures were noticed under FreeBSD 9.0.
2012-03-23test_tryopen: fix horribly-named test for EACCES
We can't actually test for EPERM without changing permissions/ownership, and we can't do that without root...
2012-03-22test/lib_read_write: increase test reliability
IO#readpartial may not drain the socket buffers enough for kgio_write to succeed on some platforms. So use IO#read for read-in-full behavior.
2012-03-19test/*: remove assert_nothing_raised
It makes test failures hard to track down, tests will already fail if exceptions are thrown and we'll get nice backtraces.
2012-03-07test_poll: workaround for timing-sensitive test on slow hosts
poll(2) may return successfully before it gets interrupted by the signal. Found and fix confirmed by 375gnu on the kgio mailing list. ref: <CAAB-Kcm=_CRa4UoSQt+C4cHk6z2Rpfsv6_KXPHV3R34Gt6sLiQ@mail.gmail.com>
2012-03-05test: increase delta range for timing-sensitive test
This appears to be needed for Debian GNU/kFreeBSD under KVM.
2012-03-05autopush: fix/enable under Debian GNU/kFreeBSD
It seems autopush support in our autopush code has always been broken outside of Linux-based systems, as we never marked the socket as having pending data.
2012-01-08test/test_autopush: skip strace tests if not available
No need to completely fail on a test.
2011-11-17connect,tryopen: set close-on-exec flag for new fds on Ruby 2.0+
All IO objects created by Kgio will have FD_CLOEXEC descriptor flag set on it when run under Ruby 2.0.0dev. This matches the upcoming behavior of Ruby 2.0.0dev for IO objects in the core and standard library. This change does not affect users on Ruby 1.9.3 and earlier. accept()-ed sockets in kgio have _always_ had FD_CLOEXEC set by default.
2011-11-15tests: remove tests for IO#nonblock? after accept
There's no point in testing a Ruby implementation detail and these tests fail under OpenBSD where the accept()-ed socket inherits the O_NONBLOCK flag from the parent.
2011-08-29test_poll: test for closing a polled IO in sighandler
This needs to work similarly to IO.select.
2011-07-06export SOCK_NONBLOCK, SOCK_CLOEXEC constants in Kgio
It's more reliable than relying on IO::NONBLOCK and Fcntl::FD_CLOEXEC constants. The existing constants are not guaranteed to be equivalent to what accept4() takes even though the current Linux implementation does it this way.
2011-06-15Kgio::File includes Kgio::PipeMethods module
Kgio::File may be used to open FIFOs, so non-blocking I/O is still useful in that context.
2011-06-14add timeout to kgio_wait_{read,writ}able
io/wait doesn't have an IO#wait_writable method, yet[1] and IO#wait checks FIONREAD which makes it unsuitable for certain descriptors. This method uses the new rb_wait_for_single_fd() function in Ruby 1.9.r. This internally uses ppoll() under Linux, meaning it performs the same regardless of the FD used. [1] http://redmine.ruby-lang.org/issues/4647 [2] http://redmine.ruby-lang.org/issues/4849
2011-05-20Kgio.poll: ensure EINTR never gets raised
Retry on a zero timeout if we get interrupted even if the timeout expired. This is also what IO.select does in Ruby itself.
2011-05-13Kgio.tryopen => Kgio::File.tryopen
This will allow users to subclass Kgio::File and override certain behavior (e.g. overriding "#each").
2011-05-13return Kgio::File for Kgio.tryopen
This also allows us to return/override #to_path and #path if necessary, but so far everything works with MRI 1.8, MRI 1.9, and Rubinius.
2011-05-13add Kgio.tryopen method
For the case where a file is readable, it's faster to just call open() instead of stat()-ing and then calling open(). open() failures are still relatively cheap, too, they're still more expensive than a failed stat() but cheaper than raising an exception.
2011-05-05test_cross_thread_close: disable on RUBY_ENGINE != "ruby"
These aren't well-defined semantics...
2011-05-05read_write: call rb_str_modify() before rb_str_resize()
This is needed under Ruby trunk if the string is not actually resized.