xref: /netbsd-src/external/gpl3/gdb/dist/sim/testsuite/cris/c/stat3.c (revision 4b169a6ba595ae283ca507b26b15fdff40495b1c)
1 /* Simulator options:
2 #sim: --sysroot=$pwd
3 */
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include <stdlib.h>
10 
main(int argc,char * argv[])11 int main (int argc, char *argv[])
12 {
13   /* Pick a regular file we know will always be in the sim builddir.  */
14   char path[1024] = "/Makefile";
15   struct stat buf;
16 
17   if (stat (".", &buf) != 0
18       || !S_ISDIR (buf.st_mode))
19     {
20       fprintf (stderr, "cwd is not a directory\n");
21       return 1;
22     }
23   if (stat (path, &buf) != 0
24       || !S_ISREG (buf.st_mode))
25     {
26       fprintf (stderr, "%s: is not a regular file\n", path);
27       return 1;
28     }
29   printf ("pass\n");
30   exit (0);
31 }
32