Update release-README after completing the 2.43 release.
[binutils-gdb.git] / sim / testsuite / cris / c / readlink2.c
blob235817f4ebbc0c569727acb19024054b9f4a2f30
1 /*
2 #progos: linux
3 */
5 #include <unistd.h>
6 #include <errno.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
11 int main (int argc, char *argv[])
13 char buf[1024];
14 char buf2[1024];
15 int err;
17 /* This is a special feature handled in the simulator. The "42"
18 should be formed from getpid () if this was a real program. */
19 err = readlink ("/proc/42/exe", buf, sizeof (buf));
20 if (err < 0)
22 if (err == -1 && errno == ENOSYS)
23 printf ("ENOSYS\n");
24 printf ("xyzzy\n");
25 exit (0);
28 /* Don't use an abort in the following; it might cause the printf to
29 not make it all the way to output and make debugging more
30 difficult. */
32 /* We assume the program is called with no path, so we might need to
33 prepend it. */
34 if (getcwd (buf2, sizeof (buf2)) != buf2)
36 perror ("getcwd");
37 exit (1);
40 if (argv[0][0] == '/')
42 #ifdef SYSROOTED
43 if (strchr (argv[0] + 1, '/') != NULL)
45 printf ("%s != %s\n", argv[0], strrchr (argv[0] + 1, '/'));
46 exit (1);
48 #endif
49 if (strcmp (argv[0], buf) != 0)
51 printf ("%s != %s\n", buf, argv[0]);
52 exit (1);
55 else if (argv[0][0] != '.')
57 if (buf2[strlen (buf2) - 1] != '/')
58 strcat (buf2, "/");
59 strcat (buf2, argv[0]);
60 if (strcmp (buf2, buf) != 0)
62 printf ("%s != %s\n", buf, buf2);
63 exit (1);
66 else
68 strcat (buf2, argv[0] + 1);
69 if (strcmp (buf, buf2) != 0)
71 printf ("%s != %s\n", buf, buf2);
72 exit (1);
76 printf ("pass\n");
77 exit (0);