OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [sim/] [testsuite/] [sim/] [cris/] [c/] [readlink4.c] - Diff between revs 24 and 157

Only display areas with differences | Details | Blame | View Log

Rev 24 Rev 157
/* Check for corner case: readlink of too-long name.
/* Check for corner case: readlink of too-long name.
#notarget: cris*-*-elf
#notarget: cris*-*-elf
*/
*/
 
 
#include <unistd.h>
#include <unistd.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <errno.h>
#include <errno.h>
#include <stdarg.h>
#include <stdarg.h>
 
 
void bye (const char *s, int i)
void bye (const char *s, int i)
{
{
  fprintf (stderr, "%s: %d\n", s, i);
  fprintf (stderr, "%s: %d\n", s, i);
  fflush (NULL);
  fflush (NULL);
  abort ();
  abort ();
}
}
 
 
int main (int argc, char *argv[])
int main (int argc, char *argv[])
{
{
  char *buf;
  char *buf;
  char buf2[1024];
  char buf2[1024];
  int max, i;
  int max, i;
 
 
  /* We assume this limit is what we see in the simulator as well.  */
  /* We assume this limit is what we see in the simulator as well.  */
#ifdef PATH_MAX
#ifdef PATH_MAX
  max = PATH_MAX;
  max = PATH_MAX;
#else
#else
  max = pathconf (argv[0], _PC_PATH_MAX);
  max = pathconf (argv[0], _PC_PATH_MAX);
#endif
#endif
 
 
  max *= 10;
  max *= 10;
 
 
  if (max <= 0)
  if (max <= 0)
    bye ("path_max", max);
    bye ("path_max", max);
 
 
  if ((buf = malloc (max + 1)) == NULL)
  if ((buf = malloc (max + 1)) == NULL)
    bye ("malloc", 0);
    bye ("malloc", 0);
 
 
  strcat (buf, argv[0]);
  strcat (buf, argv[0]);
 
 
  if (rindex (buf, '/') == NULL)
  if (rindex (buf, '/') == NULL)
    strcat (buf, "./");
    strcat (buf, "./");
 
 
  for (i = rindex (buf, '/') - buf + 1; i < max; i++)
  for (i = rindex (buf, '/') - buf + 1; i < max; i++)
    buf[i] = 'a';
    buf[i] = 'a';
 
 
  buf [i] = 0;
  buf [i] = 0;
 
 
  i = readlink (buf, buf2, sizeof (buf2) - 1);
  i = readlink (buf, buf2, sizeof (buf2) - 1);
  if (i != -1)
  if (i != -1)
     bye ("i", i);
     bye ("i", i);
 
 
  if (errno != ENAMETOOLONG)
  if (errno != ENAMETOOLONG)
    {
    {
      perror (buf);
      perror (buf);
      bye ("errno", errno);
      bye ("errno", errno);
    }
    }
 
 
  printf ("pass\n");
  printf ("pass\n");
  exit (0);
  exit (0);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.