Back to index

glibc  2.9
Defines | Functions
tst-memstream1.c File Reference
#include <mcheck.h>
#include <stdio.h>
#include "../test-skeleton.c"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define CHAR_T   char
#define W(o)   o
#define OPEN_MEMSTREAM   open_memstream
#define S(s)   S1 (s)
#define S1(s)   #s
#define TEST_FUNCTION   do_test ()

Functions

static void mcheck_abort (enum mcheck_status ev)
static int do_test (void)

Define Documentation

#define CHAR_T   char

Definition at line 6 of file tst-memstream1.c.

Definition at line 8 of file tst-memstream1.c.

#define S (   s)    S1 (s)

Definition at line 11 of file tst-memstream1.c.

#define S1 (   s)    #s

Definition at line 12 of file tst-memstream1.c.

#define TEST_FUNCTION   do_test ()

Definition at line 88 of file tst-memstream1.c.

#define W (   o)    o

Definition at line 7 of file tst-memstream1.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 24 of file tst-memstream1.c.

{
  mcheck_pedantic (mcheck_abort);

  CHAR_T *buf = (CHAR_T *) 1l;
  size_t len = 12345;
  FILE *fp = OPEN_MEMSTREAM (&buf, &len);
  if (fp == NULL)
    {
      printf ("%s failed\n", S(OPEN_MEMSTREAM));
      return 1;
    }

  if (fflush (fp) != 0)
    {
      puts ("fflush failed");
      return 1;
    }

  if (len != 0)
    {
      puts ("string after no write not empty");
      return 1;
    }
  if (buf == (CHAR_T *) 1l)
    {
      puts ("buf not updated");
      return 1;
    }
  if (buf[0] != W('\0'))
    {
      puts ("buf[0] != 0");
      return 1;
    }

  buf = (CHAR_T *) 1l;
  len = 12345;
  if (fclose (fp) != 0)
    {
      puts ("fclose failed");
      return 1;
    }

  if (len != 0)
    {
      puts ("string after close with no write not empty");
      return 1;
    }
  if (buf == (CHAR_T *) 1l)
    {
      puts ("buf not updated");
      return 1;
    }
  if (buf[0] != W('\0'))
    {
      puts ("buf[0] != 0");
      return 1;
    }

  free (buf);

  return 0;
}

Here is the call graph for this function:

static void mcheck_abort ( enum mcheck_status  ev) [static]

Definition at line 16 of file tst-memstream1.c.

{
  printf ("mecheck failed with status %d\n", (int) ev);
  exit (1);
}

Here is the call graph for this function:

Here is the caller graph for this function: