Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
b6cb5c3e
Commit
b6cb5c3e
authored
May 01, 2018
by
Fabrice de Gans-Riberi
Browse files
Fix stuff
parent
d4b5281d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
29 deletions
+27
-29
googletest/src/gtest-death-test.cc
googletest/src/gtest-death-test.cc
+27
-29
No files found.
googletest/src/gtest-death-test.cc
View file @
b6cb5c3e
...
@@ -63,6 +63,7 @@
...
@@ -63,6 +63,7 @@
# endif // GTEST_OS_QNX
# endif // GTEST_OS_QNX
# if GTEST_OS_FUCHSIA
# if GTEST_OS_FUCHSIA
# include <fdio/io.h>
# include <launchpad/launchpad.h>
# include <launchpad/launchpad.h>
# include <zircon/syscalls.h>
# include <zircon/syscalls.h>
# endif // GTEST_OS_FUCHSIA
# endif // GTEST_OS_FUCHSIA
...
@@ -543,7 +544,9 @@ bool DeathTestImpl::Passed(bool status_ok) {
...
@@ -543,7 +544,9 @@ bool DeathTestImpl::Passed(bool status_ok) {
if
(
!
spawned
())
if
(
!
spawned
())
return
false
;
return
false
;
const
std
::
string
error_message
=
GetCapturedStderr
();
// FIXME: This isn't working.
//const std::string error_message = GetCapturedStderr();
const
std
::
string
error_message
=
""
;
bool
success
=
false
;
bool
success
=
false
;
Message
buffer
;
Message
buffer
;
...
@@ -808,7 +811,7 @@ class FuchsiaDeathTest : public DeathTestImpl {
...
@@ -808,7 +811,7 @@ class FuchsiaDeathTest : public DeathTestImpl {
const
int
line_
;
const
int
line_
;
zx_handle_t
child_process_
;
zx_handle_t
child_process_
;
//
zx_handle_t
crash_port
_;
zx_handle_t
pipe_handle
_
;
};
};
// Utility class for accumulating command-line arguments.
// Utility class for accumulating command-line arguments.
...
@@ -840,6 +843,10 @@ class Arguments {
...
@@ -840,6 +843,10 @@ class Arguments {
return
&
args_
[
0
];
return
&
args_
[
0
];
}
}
int
size
()
{
return
args_
.
size
()
-
1
;
}
private:
private:
std
::
vector
<
char
*>
args_
;
std
::
vector
<
char
*>
args_
;
};
};
...
@@ -851,8 +858,6 @@ int FuchsiaDeathTest::Wait() {
...
@@ -851,8 +858,6 @@ int FuchsiaDeathTest::Wait() {
if
(
!
spawned
())
if
(
!
spawned
())
return
0
;
return
0
;
ReadAndInterpretStatusByte
();
// Wait for child process to terminate.
// Wait for child process to terminate.
zx_status_t
status_zx
;
zx_status_t
status_zx
;
zx_signals_t
signals
;
zx_signals_t
signals
;
...
@@ -863,15 +868,11 @@ int FuchsiaDeathTest::Wait() {
...
@@ -863,15 +868,11 @@ int FuchsiaDeathTest::Wait() {
&
signals
);
&
signals
);
GTEST_DEATH_TEST_CHECK_
(
status_zx
==
ZX_OK
);
GTEST_DEATH_TEST_CHECK_
(
status_zx
==
ZX_OK
);
// Do we need this?
// Close the pipe.
// // Attempt to read the crash port.
status_zx
=
zx_handle_close
(
pipe_handle_
);
// zx_port_packet_t packet;
GTEST_DEATH_TEST_CHECK_
(
status_zx
==
ZX_OK
);
// status = zx_port_wait(crash_port_, past, &packet, 1)
// if (status == ZX_ERR_TIMED_OUT) {
ReadAndInterpretStatusByte
();
// // Process did not crash.
// set_outcome(LIVED);
// return status();
// }
zx_info_process_t
buffer
;
zx_info_process_t
buffer
;
size_t
actual
;
size_t
actual
;
...
@@ -903,17 +904,21 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
...
@@ -903,17 +904,21 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
return
EXECUTE_TEST
;
return
EXECUTE_TEST
;
}
}
// Create the crash port to report on.
// FIXME: This isn't working on Fuchsia.
// zx_status_t status = zx_port_create(0, &crash_port_);
// CaptureStderr();
// GTEST_DEATH_TEST_CHECK_(status == ZX_OK);
CaptureStderr
();
// Flush the log buffers since the log streams are shared with the child.
// Flush the log buffers since the log streams are shared with the child.
FlushInfoLog
();
FlushInfoLog
();
// Create the pipe
zx_status_t
status
;
uint32_t
id
;
status
=
fdio_pipe_half
(
&
pipe_handle_
,
&
id
);
GTEST_DEATH_TEST_CHECK_
(
status
>=
0
);
set_read_fd
(
status
);
// Build the child process launcher.
// Build the child process launcher.
launchpad_t
*
lp
;
launchpad_t
*
lp
;
zx_status_t
status
;
status
=
launchpad_create
(
ZX_HANDLE_INVALID
,
"processname"
,
&
lp
);
status
=
launchpad_create
(
ZX_HANDLE_INVALID
,
"processname"
,
&
lp
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
...
@@ -922,7 +927,7 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
...
@@ -922,7 +927,7 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
status
=
launchpad_add_pipe
(
lp
,
&
write_fd
,
read_fd
());
status
=
launchpad_add_pipe
(
lp
,
&
write_fd
,
read_fd
());
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
// Build the child command line.
// Build the child
process
command line.
const
std
::
string
filter_flag
=
const
std
::
string
filter_flag
=
std
::
string
(
"--"
)
+
GTEST_FLAG_PREFIX_
+
kFilterFlag
+
"="
std
::
string
(
"--"
)
+
GTEST_FLAG_PREFIX_
+
kFilterFlag
+
"="
+
info
->
test_case_name
()
+
"."
+
info
->
name
();
+
info
->
test_case_name
()
+
"."
+
info
->
name
();
...
@@ -936,22 +941,15 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
...
@@ -936,22 +941,15 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
args
.
AddArgument
(
filter_flag
.
c_str
());
args
.
AddArgument
(
filter_flag
.
c_str
());
args
.
AddArgument
(
internal_flag
.
c_str
());
args
.
AddArgument
(
internal_flag
.
c_str
());
// Set the command line arguments.
status
=
launchpad_load_from_file
(
lp
,
args
.
Argv
()[
0
]);
status
=
launchpad_load_from_file
(
lp
,
args
.
Argv
()[
0
]);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
status
=
launchpad_set_args
(
lp
,
GetArgvs
()
.
size
()
+
2
,
args
.
Argv
());
status
=
launchpad_set_args
(
lp
,
args
.
size
(),
args
.
Argv
());
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
// Launch the child process.
// Launch the child process.
zx_handle_t
proc
;
status
=
launchpad_go
(
lp
,
&
child_process_
,
nullptr
);
const
char
*
errmsg
;
status
=
launchpad_go
(
lp
,
&
proc
,
&
errmsg
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
child_process_
=
proc
;
// bind the crash port. This should be moved to before launching the process.
// FIXME: I don't think this is necessary
// status = zx_task_bind_exception_port(child_process_, crash_port_, 0xabcabc, 0);
// GTEST_DEATH_TEST_CHECK_(status == ZX_OK);
set_spawned
(
true
);
set_spawned
(
true
);
return
OVERSEE_TEST
;
return
OVERSEE_TEST
;
...
...
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