xref: /netbsd-src/external/gpl3/gdb/dist/sim/testsuite/cris/c/rename2.c (revision 4b169a6ba595ae283ca507b26b15fdff40495b1c)
1 /* Test some execution paths for error cases.
2 #cc: additional_flags=-Wl,--section-start=.startup=0x8000
3    The linker option is for sake of newlib, where the default program
4    layout starts at address 0.  We need to change the layout so
5    there's no memory at 0, as all sim error checking is "lazy",
6    depending on lack of memory mapping.  */
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <errno.h>
11 
err(const char * s)12 void err (const char *s)
13 {
14   perror (s);
15   abort ();
16 }
17 
main(int argc,char * argv[])18 int main (int argc, char *argv[])
19 {
20   if (rename (argv[0], NULL) != -1
21       || errno != EFAULT)
22     err ("rename 1 ");
23 
24   errno = 0;
25 
26   if (rename (NULL, argv[0]) != -1
27       || errno != EFAULT)
28     err ("rename 2");
29 
30   printf ("pass\n");
31   return 0;
32 }
33