diff --git a/test/multiprocess.h b/test/multiprocess.h index 9a221bb3..61df98b5 100644 --- a/test/multiprocess.h +++ b/test/multiprocess.h @@ -15,6 +15,7 @@ #ifndef CRASHPAD_TEST_MULTIPROCESS_H_ #define CRASHPAD_TEST_MULTIPROCESS_H_ +#include #include #include "base/macros.h" @@ -28,6 +29,12 @@ namespace internal { struct MultiprocessInfo; } // namespace internal +#if defined(OS_FUCHSIA) +using ReturnCodeType = int64_t; +#else +using ReturnCodeType = int; +#endif + //! \brief Manages a multiprocess test. //! //! These tests are `fork()`-based. The parent and child processes are able to @@ -76,7 +83,7 @@ class Multiprocess { //! \brief Sets the expected termination reason and code. //! - //! The default expected termination reasaon is + //! The default expected termination reason is //! TerminationReason::kTerminationNormal, and the default expected //! termination code is `EXIT_SUCCESS` (`0`). //! @@ -91,7 +98,8 @@ class Multiprocess { //! TerminationReason::kTerminationSignal, this is the signal that is //! expected to kill the child. On Linux platforms, SIG_DFL will be //! installed for \a code in the child process. - void SetExpectedChildTermination(TerminationReason reason, int code); + void SetExpectedChildTermination(TerminationReason reason, + ReturnCodeType code); #if !defined(OS_WIN) //! \brief Sets termination reason and code appropriately for a child that @@ -211,7 +219,7 @@ class Multiprocess { virtual void MultiprocessChild() = 0; internal::MultiprocessInfo* info_; - int code_; + ReturnCodeType code_; TerminationReason reason_; DISALLOW_COPY_AND_ASSIGN(Multiprocess); diff --git a/test/multiprocess_exec_fuchsia.cc b/test/multiprocess_exec_fuchsia.cc index 9c68b7fd..eff522b0 100644 --- a/test/multiprocess_exec_fuchsia.cc +++ b/test/multiprocess_exec_fuchsia.cc @@ -87,7 +87,7 @@ void Multiprocess::Run() { } void Multiprocess::SetExpectedChildTermination(TerminationReason reason, - int code) { + ReturnCodeType code) { EXPECT_EQ(info_, nullptr) << "SetExpectedChildTermination() must be called before Run()"; reason_ = reason; @@ -95,7 +95,15 @@ void Multiprocess::SetExpectedChildTermination(TerminationReason reason, } void Multiprocess::SetExpectedChildTerminationBuiltinTrap() { - SetExpectedChildTermination(kTerminationNormal, -1); + // TODO(scottmg): Once + // https://fuchsia-review.googlesource.com/c/fuchsia/+/256771 lands, remove + // this #ifdef, and always use ZX_TASK_RETCODE_EXCEPTION_KILL. +#if defined(ZX_TASK_RETCODE_EXCEPTION_KILL) + constexpr ReturnCodeType kExpectedReturnCode = ZX_TASK_RETCODE_EXCEPTION_KILL; +#else + constexpr ReturnCodeType kExpectedReturnCode = -1; +#endif + SetExpectedChildTermination(kTerminationNormal, kExpectedReturnCode); } Multiprocess::~Multiprocess() { diff --git a/test/multiprocess_exec_win.cc b/test/multiprocess_exec_win.cc index 38978186..b75f8f57 100644 --- a/test/multiprocess_exec_win.cc +++ b/test/multiprocess_exec_win.cc @@ -58,7 +58,7 @@ void Multiprocess::Run() { } void Multiprocess::SetExpectedChildTermination(TerminationReason reason, - int code) { + ReturnCodeType code) { EXPECT_EQ(info_, nullptr) << "SetExpectedChildTermination() must be called before Run()"; reason_ = reason; diff --git a/test/multiprocess_posix.cc b/test/multiprocess_posix.cc index 2e0c3856..d2de3184 100644 --- a/test/multiprocess_posix.cc +++ b/test/multiprocess_posix.cc @@ -154,7 +154,7 @@ void Multiprocess::Run() { } void Multiprocess::SetExpectedChildTermination(TerminationReason reason, - int code) { + ReturnCodeType code) { EXPECT_EQ(info_, nullptr) << "SetExpectedChildTermination() must be called before Run()"; reason_ = reason;