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
74a09f90
Commit
74a09f90
authored
Oct 27, 2006
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Oct 30, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localspl/tests: Add tests for EnumPorts.
parent
bffcdd0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
0 deletions
+92
-0
localmon.c
dlls/localspl/tests/localmon.c
+92
-0
No files found.
dlls/localspl/tests/localmon.c
View file @
74a09f90
...
...
@@ -59,6 +59,7 @@ static DWORD (WINAPI *pXcvDataPort)(HANDLE, LPCWSTR, PBYTE, DWORD, PBYTE, DWORD,
static
BOOL
(
WINAPI
*
pXcvClosePort
)(
HANDLE
);
static
WCHAR
emptyW
[]
=
{
0
};
static
WCHAR
invalid_serverW
[]
=
{
'\\'
,
'\\'
,
'i'
,
'n'
,
'v'
,
'a'
,
'l'
,
'i'
,
'd'
,
'_'
,
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
0
};
static
WCHAR
Monitors_LocalPortW
[]
=
{
\
'S'
,
'y'
,
's'
,
't'
,
'e'
,
'm'
,
'\\'
,
'C'
,
'u'
,
'r'
,
'r'
,
'e'
,
'n'
,
't'
,
'C'
,
'o'
,
'n'
,
't'
,
'r'
,
'o'
,
'l'
,
'S'
,
'e'
,
't'
,
'\\'
,
...
...
@@ -69,6 +70,96 @@ static WCHAR Monitors_LocalPortW[] = { \
/* ##### */
static
void
test_EnumPorts
(
void
)
{
DWORD
res
;
DWORD
level
;
LPBYTE
buffer
;
DWORD
cbBuf
;
DWORD
pcbNeeded
;
DWORD
pcReturned
;
if
(
!
pEnumPorts
)
return
;
/* valid levels are 1 and 2 */
for
(
level
=
0
;
level
<
4
;
level
++
)
{
cbBuf
=
0xdeadbeef
;
pcReturned
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
pEnumPorts
(
NULL
,
level
,
NULL
,
0
,
&
cbBuf
,
&
pcReturned
);
/* use only a short test, when we test with an invalid level */
if
(
!
level
||
(
level
>
2
))
{
/* NT4 fails with ERROR_INVALID_LEVEL (as expected)
XP succeeds with ERROR_SUCCESS () */
ok
(
(
cbBuf
==
0
)
&&
(
pcReturned
==
0
),
"(%d) returned %d with %d and %d, %d (expected 0, 0)
\n
"
,
level
,
res
,
GetLastError
(),
cbBuf
,
pcReturned
);
continue
;
}
ok
(
!
res
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
),
"(%d) returned %d with %d and %d, %d (expected '0' with "
\
"ERROR_INSUFFICIENT_BUFFER)
\n
"
,
level
,
res
,
GetLastError
(),
cbBuf
,
pcReturned
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
cbBuf
*
2
);
if
(
buffer
==
NULL
)
continue
;
pcbNeeded
=
0xdeadbeef
;
pcReturned
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
pEnumPorts
(
NULL
,
level
,
buffer
,
cbBuf
,
&
pcbNeeded
,
&
pcReturned
);
ok
(
res
,
"(%d) returned %d with %d and %d, %d (expected '!= 0')
\n
"
,
level
,
res
,
GetLastError
(),
cbBuf
,
pcReturned
);
/* We can compare the returned Data with the Registry / "win.ini",[Ports] here */
pcbNeeded
=
0xdeadbeef
;
pcReturned
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
pEnumPorts
(
NULL
,
level
,
buffer
,
cbBuf
+
1
,
&
pcbNeeded
,
&
pcReturned
);
ok
(
res
,
"(%d) returned %d with %d and %d, %d (expected '!= 0')
\n
"
,
level
,
res
,
GetLastError
(),
cbBuf
,
pcReturned
);
pcbNeeded
=
0xdeadbeef
;
pcReturned
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
pEnumPorts
(
NULL
,
level
,
buffer
,
cbBuf
-
1
,
&
pcbNeeded
,
&
pcReturned
);
ok
(
!
res
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
),
"(%d) returned %d with %d and %d, %d (expected '0' with "
\
"ERROR_INSUFFICIENT_BUFFER)
\n
"
,
level
,
res
,
GetLastError
(),
cbBuf
,
pcReturned
);
#if 0
/* The following tests crash this app with native localmon/localspl */
res = pEnumPorts(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
res = pEnumPorts(NULL, level, buffer, cbBuf, NULL, &pcReturned);
res = pEnumPorts(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
#endif
/* The Servername is ignored */
pcbNeeded
=
0xdeadbeef
;
pcReturned
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
pEnumPorts
(
emptyW
,
level
,
buffer
,
cbBuf
+
1
,
&
pcbNeeded
,
&
pcReturned
);
ok
(
res
,
"(%d) returned %d with %d and %d, %d (expected '!= 0')
\n
"
,
level
,
res
,
GetLastError
(),
cbBuf
,
pcReturned
);
pcbNeeded
=
0xdeadbeef
;
pcReturned
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
pEnumPorts
(
invalid_serverW
,
level
,
buffer
,
cbBuf
+
1
,
&
pcbNeeded
,
&
pcReturned
);
ok
(
res
,
"(%d) returned %d with %d and %d, %d (expected '!= 0')
\n
"
,
level
,
res
,
GetLastError
(),
cbBuf
,
pcReturned
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
/* ########################### */
static
void
test_InitializePrintMonitor
(
void
)
{
LPMONITOREX
res
;
...
...
@@ -150,4 +241,5 @@ START_TEST(localmon)
GET_MONITOR_FUNC
(
XcvClosePort
);
}
test_InitializePrintMonitor
();
test_EnumPorts
();
}
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