Back to index

glibc  2.9
Defines | Functions | Variables
test-assert.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 38 of file test-assert.c.


Function Documentation

static void assert1 ( void  ) [static]

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

{
  assert (1 == 2);
}

Here is the caller graph for this function:

static void assert2 ( void  ) [static]

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

{
  assert (1 == 1);
}

Here is the caller graph for this function:

static void assert3 ( void  ) [static]

Definition at line 41 of file test-assert.c.

{
  assert (2 == 3);
}

Here is the caller graph for this function:

int main ( void  )

Definition at line 47 of file test-assert.c.

{

  volatile int failed = 1;

  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, "1 == 2"))
    failed = 1;

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

  fgets (buf, 160, stderr);
  if (strstr (buf, "2 == 3"))
    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.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.c.

jmp_buf rec

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