Crashpad
Public Member Functions | Protected Member Functions | List of all members
crashpad::test::MultiprocessExec Class Reference

Manages an exec()-based multiprocess test. More...

#include "test/multiprocess_exec.h"

Inheritance diagram for crashpad::test::MultiprocessExec:
crashpad::test::Multiprocess

Public Member Functions

void SetChildCommand (const std::string &command, const std::vector< std::string > *arguments)
 Sets the command to exec() in the child. More...
 
- Public Member Functions inherited from crashpad::test::Multiprocess
void Run ()
 Runs the test. More...
 
void SetExpectedChildTermination (TerminationReason reason, int code)
 Sets the expected termination reason and code. More...
 

Protected Member Functions

void PreFork () override
 Establishes the proper testing environment prior to forking. 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 an exec()-based multiprocess test.

These tests are based on fork() and exec(). The parent process is able to communicate with the child in the same manner as a base-class Multiprocess parent. The read and write pipes appear in the child process on stdin and stdout, respectively.

Subclasses are expected to implement the parent in the same was as a base-class Multiprocess parent. The child must be implemented in an executable to be set by SetChildCommand().

Member Function Documentation

§ PreFork()

void crashpad::test::MultiprocessExec::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.

§ SetChildCommand()

void crashpad::test::MultiprocessExec::SetChildCommand ( const std::string &  command,
const std::vector< std::string > *  arguments 
)

Sets the command to exec() in the child.

This method must be called before the test can be Run().

Parameters
[in]commandThe executable’s pathname.
[in]argumentsThe command-line arguments to pass to the child process in its argv[] vector. This vector must begin at argv[1], as command is implicitly used as argv[0]. This argument may be nullptr if no command-line arguments are to be passed.

The documentation for this class was generated from the following files: