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
6a59b1a5
Commit
6a59b1a5
authored
May 29, 2022
by
Zebediah Figura
Committed by
Alexandre Julliard
Jul 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32/tests: Add some tests for connecting a UDP socket.
parent
f792b082
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
sock.c
dlls/ws2_32/tests/sock.c
+86
-0
No files found.
dlls/ws2_32/tests/sock.c
View file @
6a59b1a5
...
@@ -13049,6 +13049,91 @@ static void test_connect_time(void)
...
@@ -13049,6 +13049,91 @@ static void test_connect_time(void)
closesocket
(
client
);
closesocket
(
client
);
}
}
static
void
test_connect_udp
(
void
)
{
const
struct
sockaddr_in
bind_addr
=
{.
sin_family
=
AF_INET
,
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
)};
struct
sockaddr_in
addr
,
ret_addr
;
SOCKET
client
,
server
;
char
buffer
[
5
];
int
ret
,
len
;
client
=
socket
(
AF_INET
,
SOCK_DGRAM
,
IPPROTO_UDP
);
server
=
socket
(
AF_INET
,
SOCK_DGRAM
,
IPPROTO_UDP
);
set_blocking
(
client
,
FALSE
);
set_blocking
(
server
,
FALSE
);
SetLastError
(
0xdeadbeef
);
ret
=
send
(
client
,
"data"
,
4
,
0
);
ok
(
ret
==
-
1
,
"got %d
\n
"
,
ret
);
todo_wine
ok
(
GetLastError
()
==
WSAENOTCONN
,
"got error %lu
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
recv
(
server
,
buffer
,
sizeof
(
buffer
),
0
);
ok
(
ret
==
-
1
,
"got %d
\n
"
,
ret
);
todo_wine
ok
(
GetLastError
()
==
WSAEINVAL
,
"got error %lu
\n
"
,
GetLastError
());
ret
=
bind
(
server
,
(
const
struct
sockaddr
*
)
&
bind_addr
,
sizeof
(
bind_addr
));
ok
(
!
ret
,
"got error %lu
\n
"
,
GetLastError
());
len
=
sizeof
(
addr
);
ret
=
getsockname
(
server
,
(
struct
sockaddr
*
)
&
addr
,
&
len
);
ok
(
!
ret
,
"got error %lu
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
recv
(
server
,
buffer
,
sizeof
(
buffer
),
0
);
ok
(
ret
==
-
1
,
"got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
WSAEWOULDBLOCK
,
"got error %lu
\n
"
,
GetLastError
());
ret
=
connect
(
client
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
ok
(
!
ret
,
"got error %lu
\n
"
,
GetLastError
());
ret
=
getpeername
(
client
,
(
struct
sockaddr
*
)
&
ret_addr
,
&
len
);
ok
(
!
ret
,
"got error %lu
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
&
ret_addr
,
&
addr
,
sizeof
(
addr
)),
"addresses didn't match
\n
"
);
ret
=
getsockname
(
client
,
(
struct
sockaddr
*
)
&
ret_addr
,
&
len
);
ok
(
!
ret
,
"got error %lu
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
getpeername
(
server
,
(
struct
sockaddr
*
)
&
ret_addr
,
&
len
);
ok
(
ret
==
-
1
,
"got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
WSAENOTCONN
,
"got error %lu
\n
"
,
GetLastError
());
ret
=
send
(
client
,
"data"
,
4
,
0
);
ok
(
ret
==
4
,
"got %d
\n
"
,
ret
);
memset
(
buffer
,
0xcc
,
sizeof
(
buffer
));
ret
=
recv
(
server
,
buffer
,
sizeof
(
buffer
),
0
);
ok
(
ret
==
4
,
"got %d
\n
"
,
ret
);
ok
(
!
memcmp
(
buffer
,
"data"
,
4
),
"got %s
\n
"
,
debugstr_an
(
buffer
,
ret
));
SetLastError
(
0xdeadbeef
);
ret
=
recv
(
server
,
buffer
,
sizeof
(
buffer
),
0
);
ok
(
ret
==
-
1
,
"got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
WSAEWOULDBLOCK
,
"got error %lu
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
send
(
server
,
"data"
,
4
,
0
);
ok
(
ret
==
-
1
,
"got %d
\n
"
,
ret
);
todo_wine
ok
(
GetLastError
()
==
WSAENOTCONN
,
"got error %lu
\n
"
,
GetLastError
());
ret
=
connect
(
client
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
todo_wine
ok
(
!
ret
,
"got error %lu
\n
"
,
GetLastError
());
++
addr
.
sin_port
;
ret
=
connect
(
client
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
todo_wine
ok
(
!
ret
,
"got error %lu
\n
"
,
GetLastError
());
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_family
=
AF_UNSPEC
;
ret
=
connect
(
client
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
todo_wine
ok
(
!
ret
,
"got error %lu
\n
"
,
GetLastError
());
ret
=
getpeername
(
client
,
(
struct
sockaddr
*
)
&
ret_addr
,
&
len
);
todo_wine
ok
(
ret
==
-
1
,
"got %d
\n
"
,
ret
);
todo_wine
ok
(
GetLastError
()
==
WSAENOTCONN
,
"got error %lu
\n
"
,
GetLastError
());
closesocket
(
server
);
closesocket
(
client
);
}
START_TEST
(
sock
)
START_TEST
(
sock
)
{
{
int
i
;
int
i
;
...
@@ -13127,6 +13212,7 @@ START_TEST( sock )
...
@@ -13127,6 +13212,7 @@ START_TEST( sock )
test_timeout
();
test_timeout
();
test_tcp_reset
();
test_tcp_reset
();
test_icmp
();
test_icmp
();
test_connect_udp
();
/* this is an io heavy test, do it at the end so the kernel doesn't start dropping packets */
/* this is an io heavy test, do it at the end so the kernel doesn't start dropping packets */
test_send
();
test_send
();
...
...
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