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/] [fdopen2.c] - Diff between revs 24 and 157

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

Rev 24 Rev 157
/* Check that the syscalls implementing fdopen work trivially.
/* Check that the syscalls implementing fdopen work trivially.
#output: This is the first line of this test.\npass\n
#output: This is the first line of this test.\npass\n
*/
*/
 
 
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <fcntl.h>
 
 
void
void
perr (const char *s)
perr (const char *s)
{
{
  perror (s);
  perror (s);
  exit (1);
  exit (1);
}
}
 
 
int
int
main (void)
main (void)
{
{
  FILE *f;
  FILE *f;
  int fd;
  int fd;
  const char fname[] = "sk1test.dat";
  const char fname[] = "sk1test.dat";
  const char tsttxt1[]
  const char tsttxt1[]
    = "This is the first line of this test.\n";
    = "This is the first line of this test.\n";
  char buf[sizeof (tsttxt1)] = "";
  char buf[sizeof (tsttxt1)] = "";
 
 
  /* Write a line to stdout.  */
  /* Write a line to stdout.  */
  f = fdopen (1, "w");
  f = fdopen (1, "w");
  if (f == NULL
  if (f == NULL
      || fwrite (tsttxt1, 1, strlen (tsttxt1), f) != strlen (tsttxt1))
      || fwrite (tsttxt1, 1, strlen (tsttxt1), f) != strlen (tsttxt1))
    perr ("fdopen or fwrite");
    perr ("fdopen or fwrite");
 
 
#if 0
#if 0
  /* Unfortunately we can't get < /dev/null to the simulator with
  /* Unfortunately we can't get < /dev/null to the simulator with
     reasonable test-framework surgery.  */
     reasonable test-framework surgery.  */
 
 
  /* Try to read from stdin.  Expect EOF.  */
  /* Try to read from stdin.  Expect EOF.  */
  f = fdopen (0, "r");
  f = fdopen (0, "r");
  if (f == NULL
  if (f == NULL
      || fread (buf, 1, sizeof (buf), f) != 0
      || fread (buf, 1, sizeof (buf), f) != 0
      || feof (f) == 0
      || feof (f) == 0
      || ferror (f) != 0)
      || ferror (f) != 0)
    {
    {
      printf ("fail\n");
      printf ("fail\n");
      exit (1);
      exit (1);
    }
    }
#endif
#endif
 
 
  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.