xref: /netbsd-src/external/gpl3/gdb/dist/sim/testsuite/cris/c/readlink9.c (revision 4b169a6ba595ae283ca507b26b15fdff40495b1c)
1*4b169a6bSchristos /* Check that odd cases of readlink work.
2*4b169a6bSchristos #progos: linux
3*4b169a6bSchristos #cc: additional_flags=-DX="$pwd"
4*4b169a6bSchristos */
5*4b169a6bSchristos 
6*4b169a6bSchristos #include <unistd.h>
7*4b169a6bSchristos #include <errno.h>
8*4b169a6bSchristos #include <stdio.h>
9*4b169a6bSchristos #include <stdlib.h>
10*4b169a6bSchristos 
main(int argc,char * argv[])11*4b169a6bSchristos int main (int argc, char *argv[])
12*4b169a6bSchristos {
13*4b169a6bSchristos   /* We assume that "sim/testsuite" isn't renamed to anything that
14*4b169a6bSchristos      together with "<builddir>/" is shorter than 7 characters.  */
15*4b169a6bSchristos   char buf[7];
16*4b169a6bSchristos 
17*4b169a6bSchristos   if (readlink("/proc/42/exe", buf, sizeof (buf)) != sizeof (buf)
18*4b169a6bSchristos       || strncmp (buf, X, sizeof (buf)) != 0)
19*4b169a6bSchristos     abort ();
20*4b169a6bSchristos 
21*4b169a6bSchristos   printf ("pass\n");
22*4b169a6bSchristos   exit (0);
23*4b169a6bSchristos }
24