aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Pärtel <martin.partel@gmail.com>2023-07-15 16:32:57 +0300
committerGitHub <noreply@github.com>2023-07-15 16:32:57 +0300
commit90af90856bf537fdc5946b08bc65d4ac903e715c (patch)
tree2f66a3a9fec84f217ecfc53065fc1db3af0ae9ba
parentaff180a0607e1b6f4060fc9cbe70b10831b1b234 (diff)
parent07cd3df3e80386e4216577919939c653fcf5dfeb (diff)
downloadbindfs-90af90856bf537fdc5946b08bc65d4ac903e715c.tar.gz
Merge pull request #134 from slonopotamus/drop-nc-dependency
Rewrite socket files test in pure Ruby
-rwxr-xr-xtests/test_bindfs.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb
index fe20055..031529b 100755
--- a/tests/test_bindfs.rb
+++ b/tests/test_bindfs.rb
@@ -25,6 +25,7 @@ $LOAD_PATH << (ENV['srcdir'] || '.')
require 'common.rb'
require 'etc'
+require 'socket'
require 'tempfile'
include Errno
@@ -926,17 +927,16 @@ testenv("-ouser -onofail,nouser,,,delete-deny -o users -o auto,rename-deny,noaut
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.