process-cpp: core::testing Namespace Reference

process-cpp 3.0.0 A simple convenience library for handling processes in C++11.

Classes | Enumerations | Functions
core::testing Namespace Reference

## Classes
class | CrossProcessSync
| A cross-process synchronization primitive that supports simple wait-condition-like scenarios. More...

## Enumerations
enum | ForkAndRunResult { ForkAndRunResult::empty = 0, ForkAndRunResult::client_failed = 1 << 0, ForkAndRunResult::service_failed = 1 << 1 }
| The ForkAndRunResult enum models the different failure modes of fork_and_run. More...

## Functions
CORE_POSIX_DLL_PUBLIC ForkAndRunResult | operator| (ForkAndRunResult lhs, ForkAndRunResult rhs)
CORE_POSIX_DLL_PUBLIC ForkAndRunResult | operator& (ForkAndRunResult lhs, ForkAndRunResult rhs)
CORE_POSIX_DLL_PUBLIC ForkAndRunResult | fork_and_run (const std::function< core::posix::exit::Status()> &service, const std::function< core::posix::exit::Status()> &client)
| Forks two processes for both the service and the client. More...

## Enumeration Type Documentation

## ◆ ForkAndRunResult

enum core::testing::ForkAndRunResult
| strong

The ForkAndRunResult enum models the different failure modes of fork_and_run.

Enumerator
empty | Special value indicating no bit being set.
client_failed | The client failed.
service_failed | The service failed.

Definition at line 34 of file fork_and_run.h.

## Function Documentation

## ◆ fork_and_run()

core::testing::ForkAndRunResult core::testing::fork_and_run | ( | const std::function< core::posix::exit::Status()> & | service,
|  | const std::function< core::posix::exit::Status()> & | client
| ) |  |

Forks two processes for both the service and the client.

The function does the following:

- Forks a process for the service and runs the respective closure.
- Forks a process for the client and runs the respective closure.
- After the client has finished, the service is signalled with sigterm.

Exceptions

  std::system_error | if an error occured during process interaction.
  std::runtime_error | for signalling all other error conditions.

Parameters

  [in] | service | The service to be executed in a child process.
  [in] | client | The client to be executed in a child process.

Returns
  ForkAndRunResult indicating if either of service or client failed.

Definition at line 41 of file fork_and_run.cpp.

References empty, core::posix::wait::Result::exited, core::posix::fork(), and core::posix::exit::success.

Referenced by TEST().

Here is the call graph for this function:

## ◆ operator&()

core::testing::ForkAndRunResult core::testing::operator& | ( | ForkAndRunResult | lhs,
|  | ForkAndRunResult | rhs
| ) |  |

Definition at line 33 of file fork_and_run.cpp.

## ◆ operator|()

core::testing::ForkAndRunResult core::testing::operator| | ( | ForkAndRunResult | lhs,
|  | ForkAndRunResult | rhs
| ) |  |

Definition at line 25 of file fork_and_run.cpp.