diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2022-11-17 14:50:25 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-17 14:50:25 -0800 |
commit | ea8a7287e2b96b9c24e5e89fe863e5bfa60bfdda (patch) | |
tree | 1935b65502eb16b6913d6183fc11c6f1cf4db34d /test/fiber/test_io.rb | |
parent | 4e4b29b1a9e534554594b6f18fc0bdc462638934 (diff) | |
download | ruby-ea8a7287e2b96b9c24e5e89fe863e5bfa60bfdda.tar.gz |
Add support for `sockaddr_un` on Windows. (#6513)
* Windows: Fix warning about undefined if_indextoname()
* Windows: Fix UNIXSocket on MINGW and make .pair more reliable
* Windows: Use nonblock=true for read tests with scheduler
* Windows: Move socket detection from File.socket? to File.stat
Add S_IFSOCK to Windows and interpret reparse points accordingly.
Enable tests that work now.
* Windows: Use wide-char functions to UNIXSocket
This fixes behaviour with non-ASCII characters.
It also fixes deletion of temporary UNIXSocket.pair files.
* Windows: Add UNIXSocket tests for specifics of Windows impl.
* Windows: fix VC build due to missing _snwprintf
Avoid usage of _snwprintf, since it fails linking ruby.dll like so:
linking shared-library x64-vcruntime140-ruby320.dll
x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf
x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l
whereas linking miniruby.exe succeeds.
This patch uses snprintf on the UTF-8 string instead.
Also remove branch GetWindowsDirectoryW, since it doesn't work.
* Windows: Fix dangling symlink test failures
Co-authored-by: Lars Kanis <kanis@comcard.de>
Diffstat (limited to 'test/fiber/test_io.rb')
-rw-r--r-- | test/fiber/test_io.rb | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb index 821a169e44..de88745e57 100644 --- a/test/fiber/test_io.rb +++ b/test/fiber/test_io.rb @@ -6,14 +6,12 @@ class TestFiberIO < Test::Unit::TestCase MESSAGE = "Hello World" def test_read - omit "UNIXSocket is not defined!" unless defined?(UNIXSocket) + omit unless defined?(UNIXSocket) i, o = UNIXSocket.pair - - unless i.nonblock? && o.nonblock? - i.close - o.close - omit "I/O is not non-blocking!" + if RUBY_PLATFORM=~/mswin|mingw/ + i.nonblock = true + o.nonblock = true end message = nil @@ -46,6 +44,10 @@ class TestFiberIO < Test::Unit::TestCase 16.times.map do Thread.new do i, o = UNIXSocket.pair + if RUBY_PLATFORM=~/mswin|mingw/ + i.nonblock = true + o.nonblock = true + end scheduler = Scheduler.new Fiber.set_scheduler scheduler @@ -64,16 +66,11 @@ class TestFiberIO < Test::Unit::TestCase end def test_epipe_on_read - omit "UNIXSocket is not defined!" unless defined?(UNIXSocket) + omit unless defined?(UNIXSocket) + omit "nonblock=true isn't properly supported on Windows" if RUBY_PLATFORM=~/mswin|mingw/ i, o = UNIXSocket.pair - unless i.nonblock? && o.nonblock? - i.close - o.close - omit "I/O is not non-blocking!" - end - error = nil thread = Thread.new do |