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
a09a268f
Commit
a09a268f
authored
Jul 30, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add more AllocConsole tests.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
53f17314
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
+106
-0
console.c
dlls/kernel32/tests/console.c
+106
-0
No files found.
dlls/kernel32/tests/console.c
View file @
a09a268f
...
...
@@ -3770,6 +3770,105 @@ static void test_AttachConsole(HANDLE console)
ok
(
!
memcmp
(
buf
,
"Child"
,
5
),
"Unexpected console output
\n
"
);
}
static
void
test_AllocConsole_child
(
void
)
{
HANDLE
unbound_output
;
HANDLE
prev_output
,
prev_error
;
STARTUPINFOW
si
;
DWORD
mode
;
BOOL
res
;
GetStartupInfoW
(
&
si
);
prev_output
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
res
=
DuplicateHandle
(
GetCurrentProcess
(),
prev_output
,
GetCurrentProcess
(),
&
unbound_output
,
0
,
FALSE
,
DUPLICATE_SAME_ACCESS
);
ok
(
res
,
"DuplicateHandle failed: %u
\n
"
,
GetLastError
());
res
=
GetConsoleMode
(
unbound_output
,
&
mode
);
ok
(
res
,
"GetConsoleMode failed: %u
\n
"
,
GetLastError
());
prev_error
=
GetStdHandle
(
STD_ERROR_HANDLE
);
if
(
si
.
dwFlags
&
STARTF_USESTDHANDLES
)
{
res
=
GetConsoleMode
(
prev_error
,
&
mode
);
ok
(
!
res
&&
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"GetConsoleMode failed: %u
\n
"
,
GetLastError
());
}
FreeConsole
();
ok
(
GetStdHandle
(
STD_OUTPUT_HANDLE
)
==
prev_output
,
"GetStdHandle(STD_OUTPUT_HANDLE) = %p
\n
"
,
GetStdHandle
(
STD_OUTPUT_HANDLE
));
ok
(
GetStdHandle
(
STD_ERROR_HANDLE
)
==
prev_error
,
"GetStdHandle(STD_ERROR_HANDLE) = %p
\n
"
,
GetStdHandle
(
STD_ERROR_HANDLE
));
res
=
GetConsoleMode
(
unbound_output
,
&
mode
);
todo_wine
ok
(
!
res
&&
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"GetConsoleMode failed: %u
\n
"
,
GetLastError
());
res
=
AllocConsole
();
ok
(
res
,
"AllocConsole failed: %u
\n
"
,
GetLastError
());
if
(
si
.
dwFlags
&
STARTF_USESTDHANDLES
)
{
ok
(
GetStdHandle
(
STD_OUTPUT_HANDLE
)
==
prev_output
,
"GetStdHandle(STD_OUTPUT_HANDLE) = %p
\n
"
,
GetStdHandle
(
STD_OUTPUT_HANDLE
));
ok
(
GetStdHandle
(
STD_ERROR_HANDLE
)
==
prev_error
,
"GetStdHandle(STD_ERROR_HANDLE) = %p
\n
"
,
GetStdHandle
(
STD_ERROR_HANDLE
));
}
res
=
GetConsoleMode
(
unbound_output
,
&
mode
);
ok
(
res
,
"GetConsoleMode failed: %u
\n
"
,
GetLastError
());
FreeConsole
();
SetStdHandle
(
STD_OUTPUT_HANDLE
,
NULL
);
SetStdHandle
(
STD_ERROR_HANDLE
,
NULL
);
res
=
AllocConsole
();
ok
(
res
,
"AllocConsole failed: %u
\n
"
,
GetLastError
());
ok
(
GetStdHandle
(
STD_OUTPUT_HANDLE
)
!=
NULL
,
"GetStdHandle(STD_OUTPUT_HANDLE) = %p
\n
"
,
GetStdHandle
(
STD_OUTPUT_HANDLE
));
ok
(
GetStdHandle
(
STD_ERROR_HANDLE
)
!=
NULL
,
"GetStdHandle(STD_ERROR_HANDLE) = %p
\n
"
,
GetStdHandle
(
STD_ERROR_HANDLE
));
res
=
GetConsoleMode
(
unbound_output
,
&
mode
);
ok
(
res
,
"GetConsoleMode failed: %u
\n
"
,
GetLastError
());
res
=
GetConsoleMode
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
&
mode
);
ok
(
res
,
"GetConsoleMode failed: %u
\n
"
,
GetLastError
());
res
=
GetConsoleMode
(
GetStdHandle
(
STD_ERROR_HANDLE
),
&
mode
);
ok
(
res
,
"GetConsoleMode failed: %u
\n
"
,
GetLastError
());
res
=
CloseHandle
(
unbound_output
);
ok
(
res
,
"CloseHandle failed: %u
\n
"
,
GetLastError
());
}
static
void
test_AllocConsole
(
void
)
{
SECURITY_ATTRIBUTES
inheritable_attr
=
{
sizeof
(
inheritable_attr
),
NULL
,
TRUE
};
STARTUPINFOA
si
=
{
sizeof
(
si
)
};
PROCESS_INFORMATION
info
;
char
**
argv
,
buf
[
MAX_PATH
];
HANDLE
pipe_read
,
pipe_write
;
BOOL
res
;
if
(
skip_nt
)
return
;
winetest_get_mainargs
(
&
argv
);
sprintf
(
buf
,
"
\"
%s
\"
console alloc_console"
,
argv
[
0
],
GetCurrentProcessId
());
res
=
CreateProcessA
(
NULL
,
buf
,
NULL
,
NULL
,
FALSE
,
CREATE_NEW_CONSOLE
,
NULL
,
NULL
,
&
si
,
&
info
);
ok
(
res
,
"CreateProcess failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
info
.
hThread
);
wait_child_process
(
info
.
hProcess
);
CloseHandle
(
info
.
hProcess
);
res
=
CreatePipe
(
&
pipe_read
,
&
pipe_write
,
&
inheritable_attr
,
0
);
ok
(
res
,
"CreatePipe failed: %u
\n
"
,
GetLastError
());
si
.
dwFlags
=
STARTF_USESTDHANDLES
;
si
.
hStdError
=
pipe_write
;
res
=
CreateProcessA
(
NULL
,
buf
,
NULL
,
NULL
,
TRUE
,
CREATE_NEW_CONSOLE
,
NULL
,
NULL
,
&
si
,
&
info
);
ok
(
res
,
"CreateProcess failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
info
.
hThread
);
wait_child_process
(
info
.
hProcess
);
CloseHandle
(
info
.
hProcess
);
CloseHandle
(
pipe_read
);
CloseHandle
(
pipe_write
);
}
START_TEST
(
console
)
{
static
const
char
font_name
[]
=
"Lucida Console"
;
...
...
@@ -3796,6 +3895,12 @@ START_TEST(console)
return
;
}
if
(
argc
==
3
&&
!
strcmp
(
argv
[
2
],
"alloc_console"
))
{
test_AllocConsole_child
();
return
;
}
/* be sure we have a clean console (and that's our own)
* FIXME: this will make the test fail (currently) if we don't run
* under X11
...
...
@@ -3938,5 +4043,6 @@ START_TEST(console)
test_GetConsoleScreenBufferInfoEx
(
hConOut
);
test_SetConsoleScreenBufferInfoEx
(
hConOut
);
test_AttachConsole
(
hConOut
);
test_AllocConsole
();
test_FreeConsole
();
}
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