tools/gg-tests.c
int expect_fatal(void (*test)()) {
  pid_t p;
  int status, ret;
  if (!test)
    return -1;

  switch (p = fork()) {
    case -1:
      REPORT_ERRNO("Fork failed");
      return -1;
    case 0:
      /* Disable stderr and syslog */
      disable_stderr();
      disable_syslog();
      /* child, run the test */
      test();
      /* get killed by a signal if test() returns */
      abort();
    default:
      /* parent, wait for the child. Return if child stopped (and we would
       * return -2) */
      if ((waitpid(p, &status, WUNTRACED) == p) && WIFEXITED(status)) {
        ret = WEXITSTATUS(status);
        if (ret == EXIT_FAILURE)
          return 0;
      }
      return -1;
  }
}
/* fork() and launch the test in a new process, expecting FATAL() */
fork() and launch the test in a new process, expecting FATAL()
fork () and launch the test in a new process expecting FATAL ()
int expect_fatal(void (*test)()) {
  pid_t p;
  int status, ret;
  if (!test)
    return -1;
  switch (p = fork()) {
    case -1:
      REPORT_ERRNO("Fork failed");
      return -1;
    case 0:
      disable_stderr();
      disable_syslog();
      test();
      abort();
    default:
      if ((waitpid(p, &status, WUNTRACED) == p) && WIFEXITED(status)) {
        ret = WEXITSTATUS(status);
        if (ret == EXIT_FAILURE)
          return 0;
      }
      return -1;
  }
}
int expect_fatal ( void ( * test ) ( ) ) { pid_t p ; int status , ret ; if ( ! test ) return -1 ; switch ( p = fork ( ) ) { case -1 : REPORT_ERRNO ( " " ) ; return -1 ; case 0 : disable_stderr ( ) ; disable_syslog ( ) ; test ( ) ; abort ( ) ; default : if ( ( waitpid ( p , & status , WUNTRACED ) == p ) && WIFEXITED ( status ) ) { ret = WEXITSTATUS ( status ) ; if ( ret == EXIT_FAILURE ) return 0 ; } return -1 ; } }
fork() and launch the test in a new process, expecting FATAL()
fork () and launch the test in a new process expecting FATAL ()
/* Disable stderr and syslog */ /* child, run the test */ /* get killed by a signal if test() returns */ /* parent, wait for the child. Return if child stopped (and we would
       * return -2) */