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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [sim/] [testsuite/] [sim/] [cris/] [c/] [openpf3.c] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 jlechner
/* Basic file operations (rename, unlink); once without sysroot.  We
2
   also test that the simulator has chdir:ed to PREFIX, when defined.  */
3
 
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <errno.h>
7
#include <sys/types.h>
8
#include <sys/stat.h>
9
#include <unistd.h>
10
 
11
#ifndef PREFIX
12
#define PREFIX
13
#endif
14
 
15
void err (const char *s)
16
{
17
  perror (s);
18
  abort ();
19
}
20
 
21
int main (int argc, char *argv[])
22
{
23
  FILE *f;
24
  struct stat buf;
25
 
26
  unlink (PREFIX "testfoo2.tmp");
27
 
28
  f = fopen ("testfoo1.tmp", "w");
29
  if (f == NULL)
30
    err ("open");
31
  fclose (f);
32
 
33
  if (rename (PREFIX "testfoo1.tmp", PREFIX "testfoo2.tmp") != 0)
34
    err ("rename");
35
 
36
  if (stat (PREFIX "testfoo2.tmp", &buf) != 0
37
      || !S_ISREG (buf.st_mode))
38
    err ("stat 1");
39
 
40
  if (stat ("testfoo2.tmp", &buf) != 0
41
      || !S_ISREG (buf.st_mode))
42
    err ("stat 2");
43
 
44
  if (unlink (PREFIX "testfoo2.tmp") != 0)
45
    err ("unlink");
46
 
47
  printf ("pass\n");
48
  return 0;
49
}

powered by: WebSVN 2.1.0

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