Crashpad
Public Member Functions | Protected Member Functions | List of all members
crashpad::test::MachMultiprocess Class Referenceabstract

Manages a Mach-aware multiprocess test. More...

#include "test/mac/mach_multiprocess.h"

Inheritance diagram for crashpad::test::MachMultiprocess:
crashpad::test::Multiprocess

Public Member Functions

void Run ()
 
- Public Member Functions inherited from crashpad::test::Multiprocess
void Run ()
 Runs the test. More...
 
void SetExpectedChildTermination (TerminationReason reason, ReturnCodeType code)
 Sets the expected termination reason and code. More...
 
void SetExpectedChildTerminationBuiltinTrap ()
 Sets termination reason and code appropriately for a child that terminates via __builtin_trap().
 

Protected Member Functions

void PreFork () override
 Establishes the proper testing environment prior to forking. More...
 
mach_port_t LocalPort () const
 Returns a receive right for the local port. More...
 
mach_port_t RemotePort () const
 Returns a send right for the remote port. More...
 
task_t ChildTask () const
 Returns a send right for the child’s task port. More...
 
- Protected Member Functions inherited from crashpad::test::Multiprocess
pid_t ChildPID () const
 Returns the child process’ process ID. More...
 
FileHandle ReadPipeHandle () const
 Returns the read pipe’s file handle. More...
 
FileHandle WritePipeHandle () const
 Returns the write pipe’s file handle. More...
 
void CloseReadPipe ()
 Closes the read pipe. More...
 
void CloseWritePipe ()
 Closes the write pipe. More...
 
void set_info (internal::MultiprocessInfo *info)
 
internal::MultiprocessInfoinfo ()
 

Additional Inherited Members

- Public Types inherited from crashpad::test::Multiprocess
enum  TerminationReason : bool
 The termination type for a child process. More...
 

Detailed Description

Manages a Mach-aware multiprocess test.

This is similar to the base Multiprocess test, but adds Mach features. The parent process has access to the child process’ task port. The parent and child processes are able to communicate via Mach IPC: each process has a receive right to its “local port” and a send right to a “remote port”, and messages sent to the remote port in one process can be received on the local port in the partner process.

Subclasses are expected to implement the parent and child by overriding the appropriate methods.

Member Function Documentation

◆ ChildTask()

task_t crashpad::test::MachMultiprocess::ChildTask ( ) const
protected

Returns a send right for the child’s task port.

This method may only be called by the parent process.

◆ LocalPort()

mach_port_t crashpad::test::MachMultiprocess::LocalPort ( ) const
protected

Returns a receive right for the local port.

This method may be called by either the parent or the child process. It returns a receive right, with a corresponding send right held in the opposing process.

◆ PreFork()

void crashpad::test::MachMultiprocess::PreFork ( )
overrideprotectedvirtual

Establishes the proper testing environment prior to forking.

Subclasses that solely implement a test should not need to override this method. Subclasses that do not implement tests but instead implement additional testing features on top of this class may override this method provided that they call the superclass’ implementation first as follows:

void PreFork() override {
ASSERT_NO_FATAL_FAILURE(Multiprocess::PreFork());
// Place subclass-specific pre-fork code here.
}

Subclass implementations may signal failure by raising their own fatal gtest assertions.

Reimplemented from crashpad::test::Multiprocess.

◆ RemotePort()

mach_port_t crashpad::test::MachMultiprocess::RemotePort ( ) const
protected

Returns a send right for the remote port.

This method may be called by either the parent or the child process. It returns a send right, with the corresponding receive right held in the opposing process.


The documentation for this class was generated from the following files:
crashpad::test::MachMultiprocess::PreFork
void PreFork() override
Establishes the proper testing environment prior to forking.
Definition: mach_multiprocess.cc:90
crashpad::test::Multiprocess::PreFork
virtual void PreFork()
Establishes the proper testing environment prior to forking.
Definition: multiprocess_posix.cc:175