Skip to content

Commit

Permalink
Merge pull request #134 from slonopotamus/drop-nc-dependency
Browse files Browse the repository at this point in the history
Rewrite socket files test in pure Ruby
  • Loading branch information
mpartel authored Jul 15, 2023
2 parents aff180a + 07cd3df commit 90af908
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/test_bindfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

require 'common.rb'
require 'etc'
require 'socket'
require 'tempfile'

include Errno
Expand Down Expand Up @@ -926,17 +927,16 @@ def odirect_data
end

# Issue #132 / PR #133
if `which nc 2> /dev/null`.strip != ''
testenv("", :title => "socket files") do
IO.popen("nc -U mnt/sock -l", "r") do |pipe|
sleep 0.1 until File.exists?('mnt/sock')
system("echo hello | nc -U -q 0 mnt/sock")
result = pipe.read
assert { result.strip == "hello" }
testenv("", :title => "socket files") do
UNIXServer.open("mnt/sock") do |server|
UNIXSocket.open("mnt/sock") do |client|
socket = server.accept
socket.write("hello")
socket.close
result = client.read
assert { result == "hello" }
end
end
else
puts "Skipping socket file test because 'nc' is not installed."
end

# FIXME: this stuff around testenv is a hax, and testenv may also exit(), which defeats the 'ensure' below.
Expand Down

0 comments on commit 90af908

Please sign in to comment.