Various socket spec failures
----------------------------
Key: JRUBY-2039
URL: http://jira.codehaus.org/browse/JRUBY-2039
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1RC1
Reporter: Ola Bini
Assignee: Ola Bini
There are nine different failures in specs for sockets, that can't be
attributed to bad specs (some specs reference AF_UNIX without guarding against
it, which is wrong).
The nine failures I have in mind are condensed in this file:
{noformat}
require 'socket'
describe "Socket#unpack_sockaddr_in" do
it "decodes the host name and port number of a packed sockaddr_in" do
sockaddr = Socket.sockaddr_in 80, '127.0.0.1'
Socket.unpack_sockaddr_in(sockaddr).should == [80, '127.0.0.1']
end
it "raises an ArgumentError when the sin_family is not AF_INET" do
sockaddr = Socket.sockaddr_un '/tmp/x'
lambda { Socket.unpack_sockaddr_in sockaddr }.should
raise_error(ArgumentError)
end
end
describe "Server class hierarchy" do
it "contains UNIXServer" do
UNIXServer.superclass.should == UNIXSocket
end
end
describe "The socket class hierarchy" do
it "has a UNIXSocket in parallel to Socket" do
Socket.ancestors.include?(UNIXSocket).should == false
UNIXSocket.ancestors.include?(Socket).should == false
UNIXSocket.superclass.should == BasicSocket
end
end
describe "Socket#getservbyname" do
it "identifies service ports " do
Socket.getservbyname('http').should == 80
Socket.getservbyname('http', 'tcp').should == 80
Socket.getservbyname('http', 'udp').should == 80
Socket.getservbyname('daytime').should == 13
end
it "raises a SocketError when the service or port is invalid" do
lambda { Socket.getservbyname('invalid') }.should raise_error(SocketError)
end
end
describe "BasicSocket#setsockopt" do
before(:each) do
@sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
end
it "sets the socket linger to 0" do
linger = [0, 0].pack("ii")
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, linger).should == 0
end
end
describe "BasicSocket#getsockopt" do
before(:each) do
@sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
end
it "gets a socket option" do
n = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_TYPE)
n.should == [Socket::SOCK_STREAM].pack("i")
end
it "raises a SystemCallError with an invalid socket option" do
lambda { @sock.getsockopt Socket::SOL_SOCKET, -1 }.should \
raise_error(Errno::ENOPROTOOPT)
end
end
{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email