Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
088b7c58
Commit
088b7c58
authored
Sep 24, 2020
by
Zebediah Figura
Committed by
Alexandre Julliard
Sep 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32/tests: Add more tests for WSASocket() parameters.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c2b089aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
97 deletions
+68
-97
sock.c
dlls/ws2_32/tests/sock.c
+68
-97
No files found.
dlls/ws2_32/tests/sock.c
View file @
088b7c58
...
@@ -2471,107 +2471,78 @@ static void test_WSASocket(void)
...
@@ -2471,107 +2471,78 @@ static void test_WSASocket(void)
int
items
,
err
,
size
,
socktype
,
i
,
j
;
int
items
,
err
,
size
,
socktype
,
i
,
j
;
UINT
pi_size
;
UINT
pi_size
;
SetLastError
(
0xdeadbeef
);
static
const
struct
ok
(
WSASocketA
(
0
,
0
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
{
"WSASocketA should have failed
\n
"
);
int
family
,
type
,
protocol
;
err
=
WSAGetLastError
();
DWORD
error
;
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
int
ret_family
,
ret_type
,
ret_protocol
;
}
sock
=
WSASocketA
(
AF_INET
,
0
,
0
,
NULL
,
0
,
0
);
tests
[]
=
ok
(
sock
!=
INVALID_SOCKET
,
"WSASocketA should have succeeded
\n
"
);
{
closesocket
(
sock
);
/* 0 */
{
0xdead
,
SOCK_STREAM
,
IPPROTO_TCP
,
WSAEAFNOSUPPORT
},
sock
=
WSASocketA
(
AF_INET
,
SOCK_STREAM
,
0
,
NULL
,
0
,
0
);
{
-
1
,
SOCK_STREAM
,
IPPROTO_TCP
,
WSAEAFNOSUPPORT
},
ok
(
sock
!=
INVALID_SOCKET
,
"WSASocketA should have succeeded
\n
"
);
{
AF_INET
,
0xdead
,
IPPROTO_TCP
,
WSAESOCKTNOSUPPORT
},
closesocket
(
sock
);
{
AF_INET
,
-
1
,
IPPROTO_TCP
,
WSAESOCKTNOSUPPORT
},
{
AF_INET
,
SOCK_STREAM
,
0xdead
,
WSAEPROTONOSUPPORT
},
SetLastError
(
0xdeadbeef
);
{
AF_INET
,
SOCK_STREAM
,
-
1
,
WSAEPROTONOSUPPORT
},
ok
(
WSASocketA
(
0
,
SOCK_STREAM
,
-
1
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
{
0xdead
,
0xdead
,
IPPROTO_TCP
,
WSAESOCKTNOSUPPORT
},
"WSASocketA should have failed
\n
"
);
{
0xdead
,
SOCK_STREAM
,
0xdead
,
WSAEAFNOSUPPORT
},
err
=
WSAGetLastError
();
{
AF_INET
,
0xdead
,
0xdead
,
WSAESOCKTNOSUPPORT
},
ok
(
err
==
WSAEPROTONOSUPPORT
,
"Expected 10043, received %d
\n
"
,
err
);
{
0xdead
,
SOCK_STREAM
,
IPPROTO_UDP
,
WSAEAFNOSUPPORT
},
SetLastError
(
0xdeadbeef
);
/* 10 */
ok
(
WSASocketA
(
0
,
-
1
,
IPPROTO_UDP
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
{
AF_INET
,
SOCK_STREAM
,
0
,
0
,
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
},
"WSASocketA should have failed
\n
"
);
{
AF_INET
,
SOCK_DGRAM
,
0
,
0
,
AF_INET
,
SOCK_DGRAM
,
IPPROTO_UDP
},
err
=
WSAGetLastError
();
{
AF_INET
,
0xdead
,
0
,
WSAESOCKTNOSUPPORT
},
ok
(
err
==
WSAESOCKTNOSUPPORT
,
"Expected 10044, received %d
\n
"
,
err
);
{
AF_INET
,
0
,
IPPROTO_TCP
,
0
,
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
},
{
AF_INET
,
0
,
IPPROTO_UDP
,
0
,
AF_INET
,
SOCK_DGRAM
,
IPPROTO_UDP
},
SetLastError
(
0xdeadbeef
);
{
AF_INET
,
0
,
0xdead
,
WSAEPROTONOSUPPORT
},
ok
(
WSASocketA
(
0
,
-
1
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
{
AF_INET
,
0
,
0
,
0
,
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
},
"WSASocketA should have failed
\n
"
);
{
AF_INET
,
SOCK_STREAM
,
IPPROTO_UDP
,
WSAEPROTONOSUPPORT
},
err
=
WSAGetLastError
();
{
AF_INET
,
SOCK_DGRAM
,
IPPROTO_TCP
,
WSAEPROTONOSUPPORT
},
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
/* 19 */
SetLastError
(
0xdeadbeef
);
{
AF_UNSPEC
,
SOCK_STREAM
,
IPPROTO_TCP
,
0
,
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
},
ok
(
WSASocketA
(
AF_INET
,
-
1
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
{
AF_UNSPEC
,
SOCK_STREAM
,
0xdead
,
WSAEPROTONOSUPPORT
},
"WSASocketA should have failed
\n
"
);
{
AF_UNSPEC
,
0xdead
,
IPPROTO_UDP
,
WSAESOCKTNOSUPPORT
},
err
=
WSAGetLastError
();
{
AF_UNSPEC
,
SOCK_STREAM
,
0
,
WSAEINVAL
},
ok
(
err
==
WSAESOCKTNOSUPPORT
,
"Expected 10044, received %d
\n
"
,
err
);
{
AF_UNSPEC
,
SOCK_DGRAM
,
0
,
WSAEINVAL
},
{
AF_UNSPEC
,
0xdead
,
0
,
WSAEINVAL
},
SetLastError
(
0xdeadbeef
);
{
AF_UNSPEC
,
0
,
IPPROTO_TCP
,
0
,
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
},
ok
(
WSASocketA
(
AF_INET
,
0
,
-
1
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
{
AF_UNSPEC
,
0
,
IPPROTO_UDP
,
0
,
AF_INET
,
SOCK_DGRAM
,
IPPROTO_UDP
},
"WSASocketA should have failed
\n
"
);
{
AF_UNSPEC
,
0
,
0xdead
,
WSAEPROTONOSUPPORT
},
err
=
WSAGetLastError
();
{
AF_UNSPEC
,
0
,
0
,
WSAEINVAL
},
ok
(
err
==
WSAEPROTONOSUPPORT
,
"Expected 10043, received %d
\n
"
,
err
);
};
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
0
,
-
1
,
-
1
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
ok
(
err
==
WSAESOCKTNOSUPPORT
,
"Expected 10044, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
-
1
,
SOCK_STREAM
,
IPPROTO_UDP
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
ok
(
err
==
WSAEAFNOSUPPORT
,
"Expected 10047, received %d
\n
"
,
err
);
sock
=
WSASocketA
(
AF_INET
,
0
,
IPPROTO_TCP
,
NULL
,
0
,
0
);
ok
(
sock
!=
INVALID_SOCKET
,
"WSASocketA should have succeeded
\n
"
);
closesocket
(
sock
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
0
,
SOCK_STREAM
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
0
,
0
,
0xdead
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
ok
(
err
==
WSAEPROTONOSUPPORT
,
"Expected 10043, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
AF_INET
,
0xdead
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
ok
(
err
==
WSAESOCKTNOSUPPORT
,
"Expected 10044, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tests
);
++
i
)
ok
(
WSASocketA
(
0
,
0xdead
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
{
"WSASocketA should have failed
\n
"
);
SetLastError
(
0xdeadbeef
);
err
=
WSAGetLastError
();
sock
=
WSASocketA
(
tests
[
i
].
family
,
tests
[
i
].
type
,
tests
[
i
].
protocol
,
NULL
,
0
,
0
);
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
todo_wine_if
(
!
tests
[
i
].
error
||
i
==
7
)
ok
(
WSAGetLastError
()
==
tests
[
i
].
error
,
"Test %u: got wrong error %u
\n
"
,
i
,
WSAGetLastError
());
if
(
tests
[
i
].
error
)
{
ok
(
sock
==
INVALID_SOCKET
,
"Test %u: expected failure
\n
"
,
i
);
}
else
{
WSAPROTOCOL_INFOA
info
;
sock
=
WSASocketA
(
0
,
0
,
IPPROTO_TCP
,
NULL
,
0
,
0
);
todo_wine_if
(
i
==
19
)
ok
(
sock
!=
INVALID_SOCKET
,
"Text %u: expected success
\n
"
,
i
);
ok
(
sock
!=
INVALID_SOCKET
,
"WSASocketA should have succeeded
\n
"
);
if
(
sock
==
INVALID_SOCKET
)
continue
;
closesocket
(
sock
);
/* SOCK_STREAM does not support IPPROTO_UDP */
size
=
sizeof
(
info
);
SetLastError
(
0xdeadbeef
);
err
=
getsockopt
(
sock
,
SOL_SOCKET
,
SO_PROTOCOL_INFOA
,
(
char
*
)
&
info
,
&
size
);
ok
(
WSASocketA
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_UDP
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
ok
(
!
err
,
"Test %u: getsockopt failed, error %u
\n
"
,
i
,
WSAGetLastError
());
"WSASocketA should have failed
\n
"
);
ok
(
info
.
iAddressFamily
==
tests
[
i
].
ret_family
,
"Test %u: got wrong family %d
\n
"
,
i
,
info
.
iAddressFamily
);
err
=
WSAGetLastError
();
ok
(
info
.
iSocketType
==
tests
[
i
].
ret_type
,
"Test %u: got wrong type %d
\n
"
,
i
,
info
.
iSocketType
);
ok
(
err
==
WSAEPROTONOSUPPORT
,
"Expected 10043, received %d
\n
"
,
err
);
todo_wine_if
(
i
==
10
||
i
==
11
||
i
==
16
)
ok
(
info
.
iProtocol
==
tests
[
i
].
ret_protocol
,
"Test %u: got wrong protocol %d
\n
"
,
i
,
info
.
iProtocol
);
/* SOCK_DGRAM does not support IPPROTO_TCP */
closesocket
(
sock
);
SetLastError
(
0xdeadbeef
);
}
ok
(
WSASocketA
(
AF_INET
,
SOCK_DGRAM
,
IPPROTO_TCP
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
}
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
ok
(
err
==
WSAEPROTONOSUPPORT
,
"Expected 10043, received %d
\n
"
,
err
);
/* Set pi_size explicitly to a value below 2*sizeof(WSAPROTOCOL_INFOA)
/* Set pi_size explicitly to a value below 2*sizeof(WSAPROTOCOL_INFOA)
* to avoid a crash on win98.
* to avoid a crash on win98.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment