Back to index

glibc  2.9
Defines | Functions | Variables
test-assert-perr.c File Reference
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <assert.h>

Go to the source code of this file.

Defines

#define NDEBUG

Functions

static void sigabrt (int unused)
static void assert1 (void)
static void assert2 (void)
static void assert3 (void)
int main (void)

Variables

jmp_buf rec
char buf [160]

Define Documentation

#define NDEBUG

Definition at line 37 of file test-assert-perr.c.


Function Documentation

static void assert1 ( void  ) [static]

Definition at line 26 of file test-assert-perr.c.

{
  assert_perror (1);
}

Here is the caller graph for this function:

static void assert2 ( void  ) [static]

Definition at line 32 of file test-assert-perr.c.

{
  assert_perror (0);
}

Here is the caller graph for this function:

static void assert3 ( void  ) [static]

Definition at line 40 of file test-assert-perr.c.

{
  assert_perror (2);
}

Here is the caller graph for this function:

int main ( void  )

Definition at line 46 of file test-assert-perr.c.

{
  volatile int failed = 1;  /* safety in presence of longjmp() */

  fclose (stderr);
  stderr = tmpfile ();
  if (!stderr)
    abort ();

  signal (SIGABRT, sigabrt);

  if (!setjmp (rec))
    assert1 ();
  else
    failed = 0;  /* should happen */

  if (!setjmp (rec))
    assert2 ();
  else
    failed = 1; /* should not happen */

  if (!setjmp (rec))
    assert3 ();
  else
    failed = 1; /* should not happen */

  rewind (stderr);
  fgets (buf, 160, stderr);
  if (!strstr(buf, strerror (1)))
    failed = 1;

  fgets (buf, 160, stderr);
  if (strstr (buf, strerror (0)))
    failed = 1;

  fgets (buf, 160, stderr);
  if (strstr (buf, strerror (2)))
    failed = 1;

  return failed;
}

Here is the call graph for this function:

static void sigabrt ( int  unused) [static]

Definition at line 18 of file test-assert-perr.c.

{
  longjmp (rec, 1);  /* recover control */
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char buf[160]

Definition at line 15 of file test-assert-perr.c.

jmp_buf rec

Definition at line 14 of file test-assert-perr.c.