Back to index

glibc  2.9
Defines | Functions | Variables
tst-basic6.c File Reference
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define BT
#define TEST_FUNCTION   do_test ()

Functions

static void * tf (void *a)
int do_test (void)

Variables

static char * p
static pthread_barrier_t b

Define Documentation

#define BT
Value:
e = pthread_barrier_wait (&b);                                       \
  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)                         \
    {                                                                \
      puts ("barrier_wait failed");                                         \
      exit (1);                                                             \
    }

Definition at line 30 of file tst-basic6.c.

#define TEST_FUNCTION   do_test ()

Definition at line 131 of file tst-basic6.c.


Function Documentation

int do_test ( void  )

Definition at line 80 of file tst-basic6.c.

{
  if (pthread_barrier_init (&b, NULL, 2) != 0)
    {
      puts ("barrier_init failed");
      exit (1);
    }

  pthread_t th;
  if (pthread_create (&th, NULL, tf, NULL) != 0)
    {
      puts ("create failed");
      exit (1);
    }

  p = getcwd (NULL, 0);
  if (p == NULL)
    {
      puts ("getcwd failed");
      exit (1);
    }

  int e;
  BT;

  if (pthread_join (th, NULL) != 0)
    {
      puts ("join failed");
      exit (1);
    }

  char *p2 = getcwd (NULL, 0);
  if (p2 == NULL)
    {
      puts ("2nd getcwd failed");
      exit (1);
    }

  if (strcmp (p, p2) != 0)
    {
      printf ("cwd after chdir mismatch: \"%s\" vs \"%s\"\n", p, p2);
      exit (1);
    }

  free (p);
  free (p2);

  return 0;
}

Here is the call graph for this function:

static void* tf ( void *  a) [static]

Definition at line 40 of file tst-basic6.c.

{
  int e;

  BT;

  char *p2 = getcwd (NULL, 0);
  if (p2 == NULL)
    {
      puts ("2nd getcwd failed");
      exit (1);
    }

  if (strcmp (p, p2) != 0)
    {
      printf ("initial cwd mismatch: \"%s\" vs \"%s\"\n", p, p2);
      exit (1);
    }

  free (p);
  free (p2);

  if (chdir ("..") != 0)
    {
      puts ("chdir failed");
      exit (1);
    }

  p = getcwd (NULL, 0);
  if (p == NULL)
    {
      puts ("getcwd failed");
      exit (1);
    }

  return a;
}

Here is the call graph for this function:


Variable Documentation

pthread_barrier_t b [static]

Definition at line 29 of file tst-basic6.c.

char* p [static]

Definition at line 27 of file tst-basic6.c.