mirror of
https://github.com/chromium/crashpad.git
synced 2025-01-14 01:08:01 +08:00
fuchsia: Update MultiprocessExec.BuiltinTrapTermination for task kill revamp
Transitional CL until ZX_TASK_RETCODE_EXCEPTION_KILL lands, which will define various ZX_TASK_RETCODE_xxx values. Change-Id: Ia3b6a4bd9a05798721b92e0b72b9beeedc0f5f27 Reviewed-on: https://chromium-review.googlesource.com/c/1486891 Commit-Queue: Scott Graham <scottmg@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
9d26012e9c
commit
dc17650336
@ -15,6 +15,7 @@
|
||||
#ifndef CRASHPAD_TEST_MULTIPROCESS_H_
|
||||
#define CRASHPAD_TEST_MULTIPROCESS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#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);
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user