Previous: , Up: process   [Contents][Index]


7.2 Tests in parent and child processes

The following API allows us to run a test function in a child process and a test function in the parent process. Example:

static cctests_parent_process_function_t parent_function;
static cctests_child_process_function_t  child_function;

void
test_1_1 (cce_destination_t upper_L)
{
  cctests_with_parent_and_child_process(upper_L,
     parent_function, child_function);
}

static void
parent_function (cce_destination_t L, int64_t child_pid)
/* This runs in the parent. */
{
  cctests_assert(L, true);
}

static void
child_function (cce_destination_t L)
/* This runs in the child. */
{
  cctests_assert(L, true);
}

This API is especially useful when we want two processes to exchange messages through pipes or sockets, or to send interprocess signals to each other.

Function Prototype: void cctests_parent_process_function_t (cce_destination_t L, int64_t child_pid)

Type of function to call in a parent process.

Function Prototype: void cctests_child_process_function_t (cce_destination_t L)

Type of function to call in a subprocess.

Function: void cctests_with_parent_and_child_process (cce_destination_t L, cctests_parent_process_function_t * parent_function, cctests_child_process_function_t * child_function)

Fork a process:


Previous: , Up: process   [Contents][Index]

This document describes version 0.4.1-devel.1 of CCTests.