Boost logo

Boost :

From: Davlet Panech (davlet_panech_at_[hidden])
Date: 2003-11-12 14:49:05


I have a few unit test programs that call UNIX fork().
If the child process returns into the Test Framework
code, any test cases that follow the fork()'ed one are
executed in both the parent and the child processes.

This is obviously a problem, I'd like the child
process to be independent from the rest of the test
suite. I mean, the child should exit once the current
test case is finished. Plus, the error counts related
to previous test cases should be discarded, such that
the exit status of the child process reflects its own
status only.

It would really help if the framework included a
function that (1) resets the error counts and (2) sets
some flag that prevents it from running any subsequent
test cases.

Usage Example:

void test_case1 ()
  pid_t pid = fork ();
  if (pid)
     // (parent process);

     // do the tests

     // Make sure the child exited with status 0
     int status;
     waitpid (pid, &status, 0);
     BOOST_CHECK_EQUAL (status, 0);
    // (child process)

    // Mark current test case as "final"
    // and reset all error counts.

    // do the tests
    // when we return the process terminates

Your thoughts?

Post your free ad now!

Boost list run by bdawes at, gregod at, cpdaniel at, john at