process-cpp  3.0.0
A simple convenience library for handling processes in C++11.
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 (ChildProcess, fork_does_not_run_atexit_handlers)
 
 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( Self  ,
mutable_access_to_the_environment_alters_the_environment   
)
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 ( 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 ( ChildProcess  ,
fork_returns_process_object_with_valid_pid_and_wait_for_returns_correct_result   
)
TEST ( ChildProcess  ,
fork_does_not_run_atexit_handlers   
)
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 ( ChildProcess  ,
ensure_that_forked_children_are_cleaned_up   
)

Definition at line 472 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 ( Environment  ,
iterating_the_environment_does_not_throw   
)

Definition at line 538 of file posix_process_test.cpp.

References core::posix::this_process::cout(), and core::posix::this_process::env::for_each().

+ Here is the call graph for this function:

TEST ( Environment  ,
specifying_default_value_for_get_returns_correct_result   
)

Definition at line 547 of file posix_process_test.cpp.

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

+ Here is the call graph for this function:

TEST ( Environment  ,
for_each_returns_correct_results   
)

Definition at line 554 of file posix_process_test.cpp.

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

+ Here is the call graph for this function:

TEST_F ( ForkedSpinningProcess  ,
throwing_access_to_process_group_id_of_a_forked_process_works   
)

Definition at line 113 of file posix_process_test.cpp.

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 ( ForkedSpinningProcess  ,
signalling_a_forked_child_makes_wait_for_return_correct_result   
)
TEST_F ( ForkedSpinningProcess  ,
observing_child_processes_for_death_works_if_child_is_signalled_with_sigkill   
)

Definition at line 411 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 ( ForkedSpinningProcess  ,
observing_child_processes_for_death_works_if_child_is_signalled_with_sigterm   
)

Definition at line 441 of file posix_process_test.cpp.

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

+ Here is the call graph for this function: