Crashpad
|
Manages an exec()
-based multiprocess test.
More...
#include "test/multiprocess_exec.h"
Public Member Functions | |
void | SetChildCommand (const base::FilePath &command, const std::vector< std::string > *arguments) |
Sets the command to exec() in the child. More... | |
void | SetChildTestMainFunction (const std::string &function_name) |
Calls SetChildCommand() to run a child test main function registered with CRASHPAD_CHILD_TEST_MAIN(). More... | |
ProcessType | ChildProcess () |
Returns a ProcessType representing the child process. More... | |
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... | |
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::MultiprocessInfo * | info () |
Additional Inherited Members | |
Public Types inherited from crashpad::test::Multiprocess | |
enum | TerminationReason : bool |
The termination type for a child process. More... | |
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().
ProcessType crashpad::test::MultiprocessExec::ChildProcess | ( | ) |
Returns a ProcessType representing the child process.
This method is only valid during the body of MultiprocessParent().
|
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:
Subclass implementations may signal failure by raising their own fatal gtest assertions.
Reimplemented from crashpad::test::Multiprocess.
void crashpad::test::MultiprocessExec::SetChildCommand | ( | const base::FilePath & | 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().
This method is useful when a custom executable is required for the child binary, however, SetChildTestMainFunction() should generally be preferred.
[in] | command | The executable’s pathname. |
[in] | arguments | The 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. |
void crashpad::test::MultiprocessExec::SetChildTestMainFunction | ( | const std::string & | function_name | ) |
Calls SetChildCommand() to run a child test main function registered with CRASHPAD_CHILD_TEST_MAIN().
This uses the same launch mechanism as SetChildCommand(), but coordinates with test/gtest_main.cc to allow for simple registration of a child processes' entry point via the helper macro, rather than needing to create a separate build target.
[in] | function_name | The name of the function as passed to CRASHPAD_CHILD_TEST_MAIN(). |