posix_process_test.cpp File Reference
`#include <core/posix/exec.h>`
`#include <core/posix/fork.h>`
`#include <core/posix/process.h>`
`#include <core/posix/signal.h>`
`#include <gmock/gmock.h>`
`#include <gtest/gtest.h>`
`#include <chrono>`
`#include <map>`
`#include <thread>`
Include dependency graph for posix_process_test.cpp:

Go to the source code of this file.

## Functions

| TEST (PosixProcess, ctor_throws_for_invalid_pid)
| TEST (PosixProcess, this_process_instance_reports_correct_pid)
| TEST (PosixProcess, this_process_instance_reports_correct_parent)
| TEST (PosixProcess, throwing_access_to_process_group_id_of_this_process_works)
| TEST (PosixProcess, non_throwing_access_to_process_group_id_of_this_process_works)
| TEST (PosixProcess, trying_to_access_process_group_of_invalid_process_throws)
| TEST (PosixProcess, trying_to_access_process_group_of_invalid_process_reports_error)
| TEST_F (ForkedSpinningProcess, throwing_access_to_process_group_id_of_a_forked_process_works)
| TEST_F (ForkedSpinningProcess, non_throwing_access_to_process_group_id_of_a_forked_process_works)
| TEST (PosixProcess, accessing_streams_of_this_process_works)
| TEST (Self, non_mutable_access_to_the_environment_returns_correct_results)
| TEST (Self, mutable_access_to_the_environment_alters_the_environment)
| TEST (Self, getting_env_var_for_empty_key_does_not_throw)
| TEST (Self, setting_env_var_for_empty_key_throws)
| TEST (ChildProcess, fork_returns_process_object_with_valid_pid_and_wait_for_returns_correct_result)
| TEST_F (ForkedSpinningProcess, signalling_a_forked_child_makes_wait_for_return_correct_result)
| TEST (ChildProcess, stopping_a_forked_child_makes_wait_for_return_correct_result)
| TEST (ChildProcess, exec_returns_process_object_with_valid_pid_and_wait_for_returns_correct_result)
| TEST (ChildProcess, exec_child_setup)
| TEST (ChildProcess, signalling_an_execd_child_makes_wait_for_return_correct_result)
| TEST (ChildProcess, stopping_an_execd_child_makes_wait_for_return_correct_result)
| TEST_F (ForkedSpinningProcess, observing_child_processes_for_death_works_if_child_is_signalled_with_sigkill)
| TEST_F (ForkedSpinningProcess, observing_child_processes_for_death_works_if_child_is_signalled_with_sigterm)
| TEST (ChildProcess, ensure_that_forked_children_are_cleaned_up)
| TEST (StreamRedirect, redirecting_stdin_stdout_stderr_works)
| TEST (Environment, iterating_the_environment_does_not_throw)
| TEST (Environment, specifying_default_value_for_get_returns_correct_result)
| TEST (Environment, for_each_returns_correct_results)

## Function Documentation

## TEST() [1/23]

TEST | ( | ChildProcess | ,
|  | ensure_that_forked_children_are_cleaned_up |
| ) |  |

Definition at line 452 of file posix_process_test.cpp.

References core::posix::fork(), core::posix::stdin, core::posix::stdout, and core::posix::exit::success.

Here is the call graph for this function:

## TEST() [2/23]

TEST | ( | ChildProcess | ,
|  | exec_child_setup |
| ) |  |

Definition at line 293 of file posix_process_test.cpp.

References core::posix::ChildProcess::cout(), core::posix::exec(), core::posix::Process::pid(), and core::posix::stdout.

Here is the call graph for this function:

## TEST() [3/23]

TEST | ( | ChildProcess | ,
|  | exec_returns_process_object_with_valid_pid_and_wait_for_returns_correct_result |
| ) |  |

Definition at line 270 of file posix_process_test.cpp.

References core::posix::exec(), core::posix::this_process::env::for_each(), core::posix::sig_kill, core::posix::wait::Result::signaled, core::posix::stdin, core::posix::stdout, and core::posix::wait::untraced.

Here is the call graph for this function:

## TEST() [4/23]

TEST | ( | ChildProcess | ,
|  | fork_returns_process_object_with_valid_pid_and_wait_for_returns_correct_result |
| ) |  |

Definition at line 186 of file posix_process_test.cpp.

References core::posix::wait::Result::exited, core::posix::exit::failure, core::posix::fork(), core::posix::Process::pid(), core::posix::stdin, core::posix::stdout, core::posix::exit::success, core::posix::wait::untraced, and core::posix::ChildProcess::wait_for().

Here is the call graph for this function:

## TEST() [5/23]

TEST | ( | ChildProcess | ,
|  | signalling_an_execd_child_makes_wait_for_return_correct_result |
| ) |  |

Definition at line 314 of file posix_process_test.cpp.

References core::posix::exec(), core::posix::this_process::env::for_each(), core::posix::sig_kill, core::posix::sig_term, core::posix::wait::Result::signaled, core::posix::stdin, core::posix::stdout, and core::posix::wait::untraced.

Here is the call graph for this function:

## TEST() [6/23]

TEST | ( | ChildProcess | ,
|  | stopping_a_forked_child_makes_wait_for_return_correct_result |
| ) |  |

Definition at line 233 of file posix_process_test.cpp.

References core::posix::ChildProcess::cin(), core::posix::ChildProcess::cout(), core::posix::exit::failure, core::posix::fork(), core::posix::Process::pid(), core::posix::Signalable::send_signal_or_throw(), core::posix::sig_kill, core::posix::sig_stop, core::posix::wait::Result::signaled, core::posix::stdin, core::posix::stdout, core::posix::wait::Result::stopped, core::posix::wait::untraced, and core::posix::ChildProcess::wait_for().

Here is the call graph for this function:

## TEST() [7/23]

TEST | ( | ChildProcess | ,
|  | stopping_an_execd_child_makes_wait_for_return_correct_result |
| ) |  |

Definition at line 353 of file posix_process_test.cpp.

References core::posix::exec(), core::posix::this_process::env::for_each(), core::posix::sig_kill, core::posix::sig_stop, core::posix::wait::Result::signaled, core::posix::stdin, core::posix::stdout, core::posix::wait::Result::stopped, and core::posix::wait::untraced.

Here is the call graph for this function:

## TEST() [8/23]

TEST | ( | Environment | ,
|  | for_each_returns_correct_results |
| ) |  |

Definition at line 534 of file posix_process_test.cpp.

References core::posix::this_process::env::for_each().

Here is the call graph for this function:

## TEST() [9/23]

TEST | ( | Environment | ,
|  | iterating_the_environment_does_not_throw |
| ) |  |

Definition at line 518 of file posix_process_test.cpp.

References core::posix::this_process::env::for_each().

Here is the call graph for this function:

## TEST() [10/23]

TEST | ( | Environment | ,
|  | specifying_default_value_for_get_returns_correct_result |
| ) |  |

Definition at line 527 of file posix_process_test.cpp.

References core::posix::this_process::env::get().

Here is the call graph for this function:

## TEST() [11/23]

TEST | ( | PosixProcess | ,
|  | accessing_streams_of_this_process_works |
| ) |  |

Definition at line 128 of file posix_process_test.cpp.

References core::posix::this_process::cerr(), and core::posix::this_process::cout().

Here is the call graph for this function:

## TEST() [12/23]

TEST | ( | PosixProcess | ,
|  | ctor_throws_for_invalid_pid |
| ) |  |

Definition at line 72 of file posix_process_test.cpp.

References EXPECT_ANY_THROW().

Here is the call graph for this function:

## TEST() [13/23]

TEST | ( | PosixProcess | ,
|  | non_throwing_access_to_process_group_id_of_this_process_works |
| ) |  |

Definition at line 93 of file posix_process_test.cpp.

References core::posix::this_process::instance(), and core::posix::Process::process_group().

Here is the call graph for this function:

## TEST() [14/23]

TEST | ( | PosixProcess | ,
|  | this_process_instance_reports_correct_parent |
| ) |  |

Definition at line 83 of file posix_process_test.cpp.

References core::posix::this_process::parent().

Here is the call graph for this function:

## TEST() [15/23]

TEST | ( | PosixProcess | ,
|  | this_process_instance_reports_correct_pid |
| ) |  |

Definition at line 78 of file posix_process_test.cpp.

References core::posix::this_process::instance().

Here is the call graph for this function:

## TEST() [16/23]

TEST | ( | PosixProcess | ,
|  | throwing_access_to_process_group_id_of_this_process_works |
| ) |  |

Definition at line 88 of file posix_process_test.cpp.

References core::posix::this_process::instance().

Here is the call graph for this function:

## TEST() [17/23]

TEST | ( | PosixProcess | ,
|  | trying_to_access_process_group_of_invalid_process_reports_error |
| ) |  |

Definition at line 106 of file posix_process_test.cpp.

References core::posix::Process::invalid(), and core::posix::Process::process_group().

Here is the call graph for this function:

## TEST() [18/23]

TEST | ( | PosixProcess | ,
|  | trying_to_access_process_group_of_invalid_process_throws |
| ) |  |

Definition at line 101 of file posix_process_test.cpp.

References EXPECT_ANY_THROW(), and core::posix::Process::invalid().

Here is the call graph for this function:

## TEST() [19/23]

TEST | ( | Self | ,
|  | getting_env_var_for_empty_key_does_not_throw |
| ) |  |

Definition at line 174 of file posix_process_test.cpp.

References core::posix::this_process::env::get().

Here is the call graph for this function:

## TEST() [20/23]

TEST | ( | Self | ,
|  | mutable_access_to_the_environment_alters_the_environment |
| ) |  |

Definition at line 155 of file posix_process_test.cpp.

References core::posix::this_process::env::get(), core::posix::this_process::env::set_or_throw(), and core::posix::this_process::env::unset_or_throw().

Here is the call graph for this function:

## TEST() [21/23]

TEST | ( | Self | ,
|  | non_mutable_access_to_the_environment_returns_correct_results |
| ) |  |

Definition at line 147 of file posix_process_test.cpp.

References core::posix::this_process::env::get().

Here is the call graph for this function:

## TEST() [22/23]

TEST | ( | Self | ,
|  | setting_env_var_for_empty_key_throws |
| ) |  |

Definition at line 179 of file posix_process_test.cpp.

References EXPECT_ANY_THROW(), and core::posix::this_process::env::set_or_throw().

Here is the call graph for this function:

## TEST() [23/23]

TEST | ( | StreamRedirect | ,
|  | redirecting_stdin_stdout_stderr_works |
| ) |  |

Definition at line 489 of file posix_process_test.cpp.

References core::posix::ChildProcess::cerr(), core::posix::ChildProcess::cin(), core::posix::ChildProcess::cout(), core::posix::exit::failure, core::posix::fork(), core::posix::Process::pid(), core::posix::Signalable::send_signal_or_throw(), core::posix::sig_kill, core::posix::stderr, core::posix::stdin, core::posix::stdout, core::posix::wait::untraced, and core::posix::ChildProcess::wait_for().

Here is the call graph for this function:

## TEST_F() [1/5]

TEST_F | ( | ForkedSpinningProcess | ,
|  | non_throwing_access_to_process_group_id_of_a_forked_process_works |
| ) |  |

Definition at line 119 of file posix_process_test.cpp.

## TEST_F() [2/5]

TEST_F | ( | ForkedSpinningProcess | ,
|  | observing_child_processes_for_death_works_if_child_is_signalled_with_sigkill |
| ) |  |

Definition at line 391 of file posix_process_test.cpp.

References core::posix::sig_kill, and core::posix::SignalTrap::stop().

Here is the call graph for this function:

## TEST_F() [3/5]

TEST_F | ( | ForkedSpinningProcess | ,
|  | observing_child_processes_for_death_works_if_child_is_signalled_with_sigterm |
| ) |  |

Definition at line 421 of file posix_process_test.cpp.

References core::posix::sig_term, and core::posix::SignalTrap::stop().

Here is the call graph for this function:

## TEST_F() [4/5]

TEST_F | ( | ForkedSpinningProcess | ,
|  | signalling_a_forked_child_makes_wait_for_return_correct_result |
| ) |  |

Definition at line 211 of file posix_process_test.cpp.

References core::posix::exit::failure, core::posix::fork(), core::posix::sig_kill, core::posix::sig_term, core::posix::wait::Result::signaled, core::posix::stdin, core::posix::stdout, and core::posix::wait::untraced.

Here is the call graph for this function:

## TEST_F() [5/5]

TEST_F | ( | ForkedSpinningProcess | ,
|  | throwing_access_to_process_group_id_of_a_forked_process_works |
| ) |  |

Definition at line 113 of file posix_process_test.cpp.