mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@9be7c7e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aeeaadaad0
commit
b53cf149ad
246 changed files with 9108 additions and 548 deletions
|
@ -1,8 +1,7 @@
|
|||
require_relative '../../../spec_helper'
|
||||
require_relative '../spec_helper'
|
||||
require_relative '../fixtures/classes'
|
||||
|
||||
describe "UNIXSocket#recvfrom" do
|
||||
|
||||
platform_is_not :windows do
|
||||
before :each do
|
||||
@path = SocketSpecs.socket_path
|
||||
|
@ -43,5 +42,56 @@ describe "UNIXSocket#recvfrom" do
|
|||
sock.close
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
with_feature :unix_socket do
|
||||
describe 'UNIXSocket#recvfrom' do
|
||||
describe 'using a socket pair' do
|
||||
before do
|
||||
@client, @server = UNIXSocket.socketpair
|
||||
@client.write('hello')
|
||||
end
|
||||
|
||||
after do
|
||||
@client.close
|
||||
@server.close
|
||||
end
|
||||
|
||||
it 'returns an Array containing the data and address information' do
|
||||
@server.recvfrom(5).should == ['hello', ['AF_UNIX', '']]
|
||||
end
|
||||
end
|
||||
|
||||
# These specs are taken from the rdoc examples on UNIXSocket#recvfrom.
|
||||
describe 'using a UNIX socket constructed using UNIXSocket.for_fd' do
|
||||
before do
|
||||
@path1 = SocketSpecs.socket_path
|
||||
@path2 = SocketSpecs.socket_path + '2'
|
||||
rm_r(@path2)
|
||||
|
||||
@client_raw = Socket.new(:UNIX, :DGRAM)
|
||||
@client_raw.bind(Socket.sockaddr_un(@path1))
|
||||
|
||||
@server_raw = Socket.new(:UNIX, :DGRAM)
|
||||
@server_raw.bind(Socket.sockaddr_un(@path2))
|
||||
|
||||
@socket = UNIXSocket.for_fd(@server_raw.fileno)
|
||||
end
|
||||
|
||||
after do
|
||||
@client_raw.close
|
||||
@server_raw.close # also closes @socket
|
||||
|
||||
rm_r @path1
|
||||
rm_r @path2
|
||||
end
|
||||
|
||||
it 'returns an Array containing the data and address information' do
|
||||
@client_raw.send('hello', 0, Socket.sockaddr_un(@path2))
|
||||
|
||||
@socket.recvfrom(5).should == ['hello', ['AF_UNIX', @path1]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue