pub fn fork<F, T>(fork_id: &str, test_name: &str, test: F) -> Result<(), Error>where
F: Fn() -> T,
T: Termination,
Expand description
Simulate a process fork.
Since this is not a true process fork, the calling code must be structured
to ensure that the child process, upon starting from the same entry point,
also reaches this same fork()
call. Recursive forks are supported; the
child branch is taken from all child processes of the fork even if it is
not directly the child of a particular branch. However, encountering the
same fork point more than once in a single execution sequence of a child
process is not (e.g., putting this call in a recursive function) and
results in unspecified behaviour.
fork_id
is a unique identifier identifying this particular fork location.
This must be stable across processes of the same executable; pointers are
not suitable stable, and string constants may not be suitably unique. The
fork_id!()
macro is the recommended way to supply this
parameter.
test_name
must exactly match the full path of the test function being
run.
If test
panics, the child process exits with a failure code immediately
rather than let the panic propagate out of the fork()
call.
ยงPanics
Panics if the environment indicates that there are already at least 16 levels of fork nesting.
Panics if std::env::current_exe()
fails determine the path to the current
executable.
Panics if any argument to the current process is not valid UTF-8.