Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
0cdd0d80
Commit
0cdd0d80
authored
Apr 25, 2009
by
Jeff Latimer
Committed by
Alexandre Julliard
Apr 27, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32/tests: Add tests for Inet_Ntop and inet_ntoa.
parent
82744c93
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
sock.c
dlls/ws2_32/tests/sock.c
+65
-0
No files found.
dlls/ws2_32/tests/sock.c
View file @
0cdd0d80
...
...
@@ -55,6 +55,9 @@
ok ( cond tmp, msg, GetCurrentThreadId(), err); \
} while (0);
/* Function pointers */
static
HMODULE
hws2_32
=
0
;
static
PCSTR
(
WINAPI
*
pInetNtop
)(
INT
,
LPVOID
,
LPSTR
,
ULONG
)
=
0
;
/**************** Structs and typedefs ***************/
...
...
@@ -1996,6 +1999,67 @@ static void test_inet_addr(void)
ok
(
addr
==
INADDR_NONE
,
"inet_addr succeeded unexpectedly
\n
"
);
}
static
void
test_addr_to_print
(
void
)
{
char
dst
[
16
];
char
dst6
[
64
];
const
char
*
pdst
;
struct
in_addr
in
;
struct
in6_addr
in6
;
u_long
addr0_Num
=
0x00000000
;
PCSTR
addr0_Str
=
"0.0.0.0"
;
u_long
addr1_Num
=
0x20201015
;
PCSTR
addr1_Str
=
"21.16.32.32"
;
u_char
addr2_Num
[
16
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0xff
,
0xfe
,
0xcC
,
0x98
,
0xbd
,
0x74
};
PCSTR
addr2_Str
=
"::fffe:cc98:bd74"
;
u_char
addr3_Num
[
16
]
=
{
0x20
,
0x30
,
0xa4
,
0xb1
};
PCSTR
addr3_Str
=
"2030:a4b1::"
;
hws2_32
=
GetModuleHandle
(
"ws2_32.dll"
);
pInetNtop
=
(
void
*
)
GetProcAddress
(
hws2_32
,
"inet_ntop"
);
in
.
s_addr
=
addr0_Num
;
pdst
=
inet_ntoa
(
*
((
struct
in_addr
*
)
&
in
.
s_addr
));
ok
(
pdst
!=
NULL
,
"inet_ntoa failed %s
\n
"
,
dst
);
ok
(
!
strcmp
(
pdst
,
addr0_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr0_Str
);
/* Test that inet_ntoa and inet_ntop return the same value */
in
.
S_un
.
S_addr
=
addr1_Num
;
pdst
=
inet_ntoa
(
*
((
struct
in_addr
*
)
&
in
.
s_addr
));
ok
(
pdst
!=
NULL
,
"inet_ntoa failed %s
\n
"
,
dst
);
ok
(
!
strcmp
(
pdst
,
addr1_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr1_Str
);
/* InetNtop became available in Vista and Win2008 */
if
(
!
pInetNtop
)
{
win_skip
(
"InetNtop not present, not executing tests
\n
"
);
return
;
}
pdst
=
pInetNtop
(
AF_INET
,(
void
*
)
&
in
.
s_addr
,
dst
,
sizeof
(
dst
));
ok
(
pdst
!=
NULL
,
"InetNtop failed %s
\n
"
,
dst
);
todo_wine
ok
(
!
strcmp
(
pdst
,
addr1_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr1_Str
);
/* Test invalid parm conditions */
pdst
=
pInetNtop
(
1
,
(
void
*
)
&
in
.
s_addr
,
dst
,
sizeof
(
dst
));
ok
(
pdst
==
NULL
,
"The pointer should not be returned (%p)
\n
"
,
pdst
);
ok
(
WSAGetLastError
()
==
WSAEAFNOSUPPORT
,
"Should be WSAEAFNOSUPPORT
\n
"
);
/* Test an zero prefixed IPV6 address */
memcpy
(
in6
.
u
.
Byte
,
addr2_Num
,
sizeof
(
addr2_Num
));
pdst
=
pInetNtop
(
AF_INET6
,(
void
*
)
&
in6
.
s6_addr
,
dst6
,
sizeof
(
dst6
));
ok
(
pdst
!=
NULL
,
"InetNtop failed %s
\n
"
,
dst6
);
todo_wine
ok
(
!
strcmp
(
pdst
,
addr2_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr2_Str
);
/* Test an zero suffixed IPV6 address */
memcpy
(
in6
.
s6_addr
,
addr3_Num
,
sizeof
(
addr3_Num
));
pdst
=
pInetNtop
(
AF_INET6
,(
void
*
)
&
in6
.
s6_addr
,
dst6
,
sizeof
(
dst6
));
ok
(
pdst
!=
NULL
,
"InetNtop failed %s
\n
"
,
dst6
);
todo_wine
ok
(
!
strcmp
(
pdst
,
addr3_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr3_Str
);
}
static
void
test_ioctlsocket
(
void
)
{
SOCKET
sock
;
...
...
@@ -2369,6 +2433,7 @@ START_TEST( sock )
test_accept
();
test_getsockname
();
test_inet_addr
();
test_addr_to_print
();
test_ioctlsocket
();
test_dns
();
test_gethostbyname_hack
();
...
...
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