daily update
[external/binutils.git] / sim / testsuite / sim / cris / c / rename2.c
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
12 void err (const char *s)
13 {
14   perror (s);
15   abort ();
16 }
17
18 int main (int argc, char *argv[])
19 {
20   /* Avoid getting files with random characters due to errors
21      elsewhere.  */
22   if (argc != 1
23       || (argv[0][0] != '.' && argv[0][0] != '/' && argv[0][0] != 'r'))
24     abort ();
25
26   if (rename (argv[0], NULL) != -1
27       || errno != EFAULT)
28     err ("rename 1 ");
29
30   errno = 0;
31
32   if (rename (NULL, argv[0]) != -1
33       || errno != EFAULT)
34     err ("rename 2");
35
36   printf ("pass\n");
37   return 0;
38 }